Completed
Branch FET-9099-unit-test-factories (8a4437)
by
unknown
171:15 queued 159:15
created
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -808,7 +808,7 @@
 block discarded – undo
808 808
 
809 809
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
810 810
 
811
-			}  else {
811
+			} else {
812 812
 				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
813 813
 				// remove malformed data
814 814
 				unset( $valid_data[ $reg_url_link ] );
Please login to merge, or discard this patch.
Spacing   +249 added lines, -250 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 	 * @param    EE_Checkout $checkout
38 38
 	 * @return    \EE_SPCO_Reg_Step_Attendee_Information
39 39
 	 */
40
-	public function __construct( EE_Checkout $checkout ) {
40
+	public function __construct(EE_Checkout $checkout) {
41 41
 		$this->_slug = 'attendee_information';
42 42
 		$this->_name = __('Attendee Information', 'event_espresso');
43
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
43
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
44 44
 		$this->checkout = $checkout;
45 45
 		$this->_reset_success_message();
46
-		$this->set_instructions( __('Please answer the following registration questions before proceeding.', 'event_espresso'));
46
+		$this->set_instructions(__('Please answer the following registration questions before proceeding.', 'event_espresso'));
47 47
 	}
48 48
 
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
53 53
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(' is a required question. Please enter a value for at least one of the options.', 'event_espresso');
54 54
 		EE_Registry::$i18n_js_strings['answer_required_questions'] = __('Please answer all required questions correctly before proceeding.', 'event_espresso');
55
-		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( __('The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', 'event_espresso'), '<br/>' );
55
+		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(__('The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', 'event_espresso'), '<br/>');
56 56
 		EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = __('An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', 'event_espresso');
57 57
 		EE_Registry::$i18n_js_strings['enter_valid_email'] = __('You must enter a valid email address.', 'event_espresso');
58 58
 		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = __('You must enter a valid email address and answer all other required questions before you can proceed.', 'event_espresso');
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		EEH_Autoloader::register_line_item_display_autoloaders();
86 86
 		$Line_Item_Display = new EE_Line_Item_Display();
87 87
 		// calculate taxes
88
-		$Line_Item_Display->display_line_item( $this->checkout->cart->get_grand_total(), array( 'set_tax_rate' => true ) );
88
+		$Line_Item_Display->display_line_item($this->checkout->cart->get_grand_total(), array('set_tax_rate' => true));
89 89
 		EE_Registry::instance()->load_helper('Line_Item');
90 90
 		/** @var $subsections EE_Form_Section_Proper[] */
91 91
 		$subsections = array(
@@ -97,33 +97,33 @@  discard block
 block discarded – undo
97 97
 			'ticket_count' 	=> array()
98 98
 		);
99 99
 		// grab the saved registrations from the transaction
100
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
101
-		if ( $registrations ) {
102
-			foreach ( $registrations as $registration ) {
103
-				if ( $registration instanceof EE_Registration ) {
100
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
101
+		if ($registrations) {
102
+			foreach ($registrations as $registration) {
103
+				if ($registration instanceof EE_Registration) {
104 104
 					// can this registration be processed during this visit ?
105
-					if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
106
-						$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
107
-						if ( ! $this->checkout->admin_request ) {
108
-							$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
109
-							$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( $template_args['ticket_count'][ $registration->ticket()->ID() ] ) ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 : 1;
110
-							$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( $this->checkout->cart->get_grand_total(), 'Ticket', array( $registration->ticket()->ID() ) );
111
-							$ticket_line_item = is_array( $ticket_line_item ) ? reset( $ticket_line_item ) : $ticket_line_item;
112
-							$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item( $ticket_line_item );
105
+					if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
106
+						$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
107
+						if ( ! $this->checkout->admin_request) {
108
+							$template_args['registrations'][$registration->reg_url_link()] = $registration;
109
+							$template_args['ticket_count'][$registration->ticket()->ID()] = isset($template_args['ticket_count'][$registration->ticket()->ID()]) ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 : 1;
110
+							$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs($this->checkout->cart->get_grand_total(), 'Ticket', array($registration->ticket()->ID()));
111
+							$ticket_line_item = is_array($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item;
112
+							$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item($ticket_line_item);
113 113
 						}
114
-						if ( $registration->is_primary_registrant() ) {
114
+						if ($registration->is_primary_registrant()) {
115 115
 							$primary_registrant = $registration->reg_url_link();
116 116
 						}
117 117
 					}
118 118
 				}
119 119
 			}
120 120
 			// print_copy_info ?
121
-			if ( $primary_registrant && count( $registrations ) > 1 && ! $this->checkout->admin_request ) {
121
+			if ($primary_registrant && count($registrations) > 1 && ! $this->checkout->admin_request) {
122 122
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
123 123
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info ? $this->_copy_attendee_info_form() : $this->_auto_copy_attendee_info();
124 124
 				// generate hidden input
125
-				if ( isset( $subsections[ $primary_registrant ] ) && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper ) {
126
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
125
+				if (isset($subsections[$primary_registrant]) && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper) {
126
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
127 127
 				}
128 128
 			}
129 129
 
@@ -135,8 +135,7 @@  discard block
 block discarded – undo
135 135
 				'html_id' 					=> $this->reg_form_name(),
136 136
 				'subsections' 			=> $subsections,
137 137
 				'layout_strategy'		=> $this->checkout->admin_request ?
138
-					new EE_Div_Per_Section_Layout() :
139
-					new EE_Template_Layout(
138
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
140 139
 						array(
141 140
 							'layout_template_file' 	=> $this->_template, // layout_template
142 141
 							'template_args' 				=> $template_args
@@ -153,61 +152,61 @@  discard block
 block discarded – undo
153 152
 	 * @param EE_Registration $registration
154 153
 	 * @return EE_Form_Section_Proper
155 154
 	 */
156
-	private function _registrations_reg_form( EE_Registration $registration ) {
157
-		EE_Registry::instance()->load_helper( 'Template' );
155
+	private function _registrations_reg_form(EE_Registration $registration) {
156
+		EE_Registry::instance()->load_helper('Template');
158 157
 		static $attendee_nmbr = 1;
159 158
 		// array of params to pass to parent constructor
160 159
 		$form_args = array(
161
-			'html_id' 				=> 'ee-registration-' . $registration->reg_url_link(),
160
+			'html_id' 				=> 'ee-registration-'.$registration->reg_url_link(),
162 161
 			'html_class' 		=> 'ee-reg-form-attendee-dv',
163 162
 			'html_style' 		=> $this->checkout->admin_request ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' : '',
164 163
 			'subsections' 		=> array(),
165 164
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
166 165
 				array(
167 166
 					'legend_class' 	=> 'spco-attendee-lgnd smaller-text lt-grey-text',
168
-					'legend_text' 	=> sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
167
+					'legend_text' 	=> sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
169 168
 				)
170 169
 			)
171 170
 		);
172 171
 		// verify that registration has valid event
173
-		if ( $registration->event() instanceof EE_Event ) {
172
+		if ($registration->event() instanceof EE_Event) {
174 173
 			$query_params = array(
175 174
 				array(
176 175
 					'Event.EVT_ID' => $registration->event()->ID(),
177 176
 					'Event_Question_Group.EQG_primary' => $registration->count() == 1 ? TRUE : FALSE
178 177
 				),
179
-				'order_by'=>array( 'QSG_order'=>'ASC' )
178
+				'order_by'=>array('QSG_order'=>'ASC')
180 179
 			);
181
-			$question_groups = $registration->event()->question_groups( $query_params );
182
-			if ( $question_groups ) {
183
-				foreach ( $question_groups as $question_group ) {
184
-					if ( $question_group instanceof EE_Question_Group ) {
185
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( $registration, $question_group );
180
+			$question_groups = $registration->event()->question_groups($query_params);
181
+			if ($question_groups) {
182
+				foreach ($question_groups as $question_group) {
183
+					if ($question_group instanceof EE_Question_Group) {
184
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form($registration, $question_group);
186 185
 						// add hidden input
187
-						$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( $registration );
186
+						$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input($registration);
188 187
 					}
189 188
 				}
190 189
 				// if we have question groups for additional attendees, then display the copy options
191 190
 				$this->_print_copy_info = $attendee_nmbr > 1 ? TRUE : $this->_print_copy_info;
192 191
 			} else {
193
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link() ] = new EE_Form_Section_HTML(
192
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link()] = new EE_Form_Section_HTML(
194 193
 					EEH_Template::locate_template(
195
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
196
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args', array()),
194
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
195
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args', array()),
197 196
 						TRUE,
198 197
 						TRUE
199 198
 					)
200 199
 				);
201 200
 				// add hidden input
202
-				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( $registration, FALSE );
201
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input($registration, FALSE);
203 202
 			}
204 203
 		}
205
-		if ( $registration->is_primary_registrant() ) {
204
+		if ($registration->is_primary_registrant()) {
206 205
 			// generate hidden input
207
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
206
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
208 207
 		}
209 208
 		$attendee_nmbr++;
210
-		return new EE_Form_Section_Proper( $form_args );
209
+		return new EE_Form_Section_Proper($form_args);
211 210
 	}
212 211
 
213 212
 
@@ -220,11 +219,11 @@  discard block
 block discarded – undo
220 219
 	 * @param bool  $additional_attendee_reg_info
221 220
 	 * @return    EE_Form_Input_Base
222 221
 	 */
223
-	private function _additional_attendee_reg_info_input( EE_Registration $registration, $additional_attendee_reg_info = TRUE ){
222
+	private function _additional_attendee_reg_info_input(EE_Registration $registration, $additional_attendee_reg_info = TRUE) {
224 223
 		// generate hidden input
225 224
 		return new EE_Hidden_Input(
226 225
 			array(
227
-				'html_id' 				=> 'additional-attendee-reg-info-' . $registration->reg_url_link(),
226
+				'html_id' 				=> 'additional-attendee-reg-info-'.$registration->reg_url_link(),
228 227
 				'default'				=> $additional_attendee_reg_info
229 228
 			)
230 229
 		);
@@ -237,22 +236,22 @@  discard block
 block discarded – undo
237 236
 	 * @param EE_Question_Group $question_group
238 237
 	 * @return EE_Form_Section_Proper
239 238
 	 */
240
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
239
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
241 240
 		// array of params to pass to parent constructor
242 241
 		$form_args = array(
243
-			'html_id' 					=> 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
242
+			'html_id' 					=> 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
244 243
 			'html_class' 			=> $this->checkout->admin_request ? 'form-table ee-reg-form-qstn-grp-dv' : 'ee-reg-form-qstn-grp-dv',
245
-			'html_label_id' 		=> 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
244
+			'html_label_id' 		=> 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
246 245
 			'subsections' 			=> array(
247
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
246
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
248 247
 			),
249 248
 			'layout_strategy' 	=> $this->checkout->admin_request ? new EE_Admin_Two_Column_Layout() : new EE_Div_Per_Section_Layout()
250 249
 		);
251 250
 		// where params
252
-		$query_params = array( 'QST_deleted' => 0 );
251
+		$query_params = array('QST_deleted' => 0);
253 252
 		// don't load admin only questions on the frontend
254
-		if ( ! $this->checkout->admin_request ) {
255
-			$query_params['QST_admin_only'] = array( '!=', TRUE );
253
+		if ( ! $this->checkout->admin_request) {
254
+			$query_params['QST_admin_only'] = array('!=', TRUE);
256 255
 		}
257 256
 		$questions = $question_group->get_many_related(
258 257
 			'Question',
@@ -264,21 +263,21 @@  discard block
 block discarded – undo
264 263
 			)
265 264
 		);
266 265
 		// filter for additional content before questions
267
-		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '', $registration, $question_group, $this ));
266
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '', $registration, $question_group, $this));
268 267
 		// loop thru questions
269
-		foreach ( $questions as $question ) {
270
-			if( $question instanceof EE_Question ){
268
+		foreach ($questions as $question) {
269
+			if ($question instanceof EE_Question) {
271 270
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
272
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
271
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
273 272
 			}
274 273
 		}
275
-		$form_args['subsections'] = apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', $form_args['subsections'], $registration, $question_group, $this );
274
+		$form_args['subsections'] = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', $form_args['subsections'], $registration, $question_group, $this);
276 275
 
277 276
 		// filter for additional content after questions
278
-		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '', $registration, $question_group, $this ));
277
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '', $registration, $question_group, $this));
279 278
 //		d( $form_args );
280
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
281
-		return apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', $question_group_reg_form, $registration, $question_group, $this );
279
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
280
+		return apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', $question_group_reg_form, $registration, $question_group, $this);
282 281
 	}
283 282
 
284 283
 
@@ -288,12 +287,12 @@  discard block
 block discarded – undo
288 287
 	 * @param EE_Question_Group $question_group
289 288
 	 * @return 	EE_Form_Section_HTML
290 289
 	 */
291
-	private function _question_group_header( EE_Question_Group $question_group ){
290
+	private function _question_group_header(EE_Question_Group $question_group) {
292 291
 		$html = '';
293 292
 		// group_name
294
-		if ( $question_group->show_group_name() && $question_group->name() != '' ) {
293
+		if ($question_group->show_group_name() && $question_group->name() != '') {
295 294
 			EE_Registry::instance()->load_helper('HTML');
296
-			if ( $this->checkout->admin_request ) {
295
+			if ($this->checkout->admin_request) {
297 296
 				$html .= EEH_HTML::br();
298 297
 				$html .= EEH_HTML::h3(
299 298
 					$question_group->name(),
@@ -307,7 +306,7 @@  discard block
 block discarded – undo
307 306
 			}
308 307
 		}
309 308
 		// group_desc
310
-		if ( $question_group->show_group_desc() && $question_group->desc() != '' ) {
309
+		if ($question_group->show_group_desc() && $question_group->desc() != '') {
311 310
 			$html .= EEH_HTML::p(
312 311
 				$question_group->desc(),
313 312
 				'',
@@ -315,7 +314,7 @@  discard block
 block discarded – undo
315 314
 			);
316 315
 
317 316
 		}
318
-		return new EE_Form_Section_HTML( $html );
317
+		return new EE_Form_Section_HTML($html);
319 318
 	}
320 319
 
321 320
 
@@ -324,14 +323,14 @@  discard block
 block discarded – undo
324 323
 	 * @access public
325 324
 	 * @return 	EE_Form_Section_Proper
326 325
 	 */
327
-	private function _copy_attendee_info_form(){
326
+	private function _copy_attendee_info_form() {
328 327
 		// array of params to pass to parent constructor
329 328
 		return new EE_Form_Section_Proper(
330 329
 			array(
331 330
 				'subsections' 			=> $this->_copy_attendee_info_inputs(),
332 331
 				'layout_strategy' 	=> new EE_Template_Layout(
333 332
 					array(
334
-						'layout_template_file' 			=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'copy_attendee_info.template.php', // layout_template
333
+						'layout_template_file' 			=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'copy_attendee_info.template.php', // layout_template
335 334
 						'begin_template_file' 			=> NULL,
336 335
 						'input_template_file' 				=> NULL,
337 336
 						'subsection_template_file' 	=> NULL,
@@ -353,8 +352,8 @@  discard block
 block discarded – undo
353 352
 	private function _auto_copy_attendee_info() {
354 353
 		return new EE_Form_Section_HTML(
355 354
 			EEH_Template::locate_template(
356
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
357
-				apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', array()),
355
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
356
+				apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', array()),
358 357
 				TRUE,
359 358
 				TRUE
360 359
 			)
@@ -373,25 +372,25 @@  discard block
 block discarded – undo
373 372
 		$copy_attendee_info_inputs = array();
374 373
 		$prev_ticket = NULL;
375 374
 		// grab the saved registrations from the transaction
376
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
377
-		foreach ( $registrations as $registration ) {
375
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
376
+		foreach ($registrations as $registration) {
378 377
 			// for all  attendees other than the primary attendee
379
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
378
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
380 379
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
381
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
380
+				if ($registration->ticket()->ID() !== $prev_ticket) {
382 381
 					$item_name = $registration->ticket()->name();
383
-					$item_name .= $registration->ticket()->description() != '' ? ' - ' . $registration->ticket()->description() : '';
384
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
385
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
382
+					$item_name .= $registration->ticket()->description() != '' ? ' - '.$registration->ticket()->description() : '';
383
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
384
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
386 385
 					);
387 386
 					$prev_ticket = $registration->ticket()->ID();
388 387
 				}
389 388
 
390
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
389
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
391 390
 				EE_Checkbox_Multi_Input(
392
-					array( $registration->ID() => sprintf( __('Attendee #%s', 'event_espresso'), $registration->count() )),
391
+					array($registration->ID() => sprintf(__('Attendee #%s', 'event_espresso'), $registration->count())),
393 392
 					array(
394
-						'html_id' 								=> 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
393
+						'html_id' 								=> 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
395 394
 						'html_class' 						=> 'spco-copy-attendee-chk ee-do-not-validate',
396 395
 						'display_html_label_text' 	=> FALSE
397 396
 					)
@@ -410,7 +409,7 @@  discard block
 block discarded – undo
410 409
 	 * @param EE_Registration $registration
411 410
 	 * @return    EE_Form_Input_Base
412 411
 	 */
413
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
412
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
414 413
 		// generate hidden input
415 414
 		return new EE_Hidden_Input(
416 415
 			array(
@@ -428,31 +427,31 @@  discard block
 block discarded – undo
428 427
 	 * @param EE_Question     $question
429 428
 	 * @return 	EE_Form_Input_Base
430 429
 	 */
431
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
430
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
432 431
 
433 432
 		// if this question was for an attendee detail, then check for that answer
434
-		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( $registration, $question->system_ID() );
433
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value($registration, $question->system_ID());
435 434
 		$answer = $answer_value === null
436
-				? EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() )	) )
435
+				? EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())))
437 436
 				: null;
438 437
 		// if NOT returning to edit an existing registration OR if this question is for an attendee property OR we still don't have an EE_Answer object
439
-		if( ! $registration->reg_url_link() || $answer_value || ! $answer instanceof EE_Answer ) {
438
+		if ( ! $registration->reg_url_link() || $answer_value || ! $answer instanceof EE_Answer) {
440 439
 			// create an EE_Answer object for storing everything in
441
-			$answer = EE_Answer::new_instance ( array(
440
+			$answer = EE_Answer::new_instance(array(
442 441
 				'QST_ID'=> $question->ID(),
443 442
 				'REG_ID'=> $registration->ID()
444 443
 			));
445 444
 		}
446 445
 		// verify instance
447
-		if( $answer instanceof EE_Answer ){
448
-			if ( ! empty( $answer_value )) {
449
-				$answer->set( 'ANS_value', $answer_value );
446
+		if ($answer instanceof EE_Answer) {
447
+			if ( ! empty($answer_value)) {
448
+				$answer->set('ANS_value', $answer_value);
450 449
 			}
451
-			$answer->cache( 'Question', $question );
452
-			$answer_cache_id =$question->system_ID() != NULL ? $question->system_ID() . '-' . $registration->reg_url_link() : $question->ID() . '-' . $registration->reg_url_link();
453
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
450
+			$answer->cache('Question', $question);
451
+			$answer_cache_id = $question->system_ID() != NULL ? $question->system_ID().'-'.$registration->reg_url_link() : $question->ID().'-'.$registration->reg_url_link();
452
+			$registration->cache('Answer', $answer, $answer_cache_id);
454 453
 		}
455
-		return $this->_generate_question_input( $registration, $question, $answer );
454
+		return $this->_generate_question_input($registration, $question, $answer);
456 455
 
457 456
 	}
458 457
 
@@ -464,31 +463,31 @@  discard block
 block discarded – undo
464 463
 	 * @param mixed EE_Answer|NULL      $answer
465 464
 	 * @return EE_Form_Input_Base
466 465
 	 */
467
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
466
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
468 467
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
469
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
470
-		add_filter( 'FHEE__EE_Question__generate_form_input__country_options', array( $this, 'use_cached_countries_for_form_input' ), 10, 4 );
471
-		add_filter( 'FHEE__EE_Question__generate_form_input__state_options', array( $this, 'use_cached_states_for_form_input' ), 10, 4 );
468
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
469
+		add_filter('FHEE__EE_Question__generate_form_input__country_options', array($this, 'use_cached_countries_for_form_input'), 10, 4);
470
+		add_filter('FHEE__EE_Question__generate_form_input__state_options', array($this, 'use_cached_states_for_form_input'), 10, 4);
472 471
 		$input_constructor_args = array(
473
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
474
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
475
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
476
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
472
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
473
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
474
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
475
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
477 476
 			'html_label_class'	=> 'ee-reg-qstn',
478 477
 		);
479
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
480
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
481
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
482
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
483
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
478
+		$input_constructor_args['html_label_id'] .= '-lbl';
479
+		if ($answer instanceof EE_Answer && $answer->ID()) {
480
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
481
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
482
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
484 483
 		}
485
-		$form_input =  $question->generate_form_input(
484
+		$form_input = $question->generate_form_input(
486 485
 			$registration,
487 486
 			$answer,
488 487
 			$input_constructor_args
489 488
 		);
490
-		remove_filter( 'FHEE__EE_Question__generate_form_input__country_options', array( $this, 'use_cached_countries_for_form_input' ) );
491
-		remove_filter( 'FHEE__EE_Question__generate_form_input__state_options', array( $this, 'use_cached_states_for_form_input' ) );
489
+		remove_filter('FHEE__EE_Question__generate_form_input__country_options', array($this, 'use_cached_countries_for_form_input'));
490
+		remove_filter('FHEE__EE_Question__generate_form_input__state_options', array($this, 'use_cached_states_for_form_input'));
492 491
 		return $form_input;
493 492
 	}
494 493
 
@@ -502,20 +501,20 @@  discard block
 block discarded – undo
502 501
 	 * @param EE_Registration $registration
503 502
 	 * @return array 2d keys are country IDs, values are their names
504 503
 	 */
505
-	public function use_cached_countries_for_form_input( $countries_list, $question, $registration, $answer ) {
506
-		$country_options = array( '' => '' );
504
+	public function use_cached_countries_for_form_input($countries_list, $question, $registration, $answer) {
505
+		$country_options = array('' => '');
507 506
 		// get possibly cached list of countries
508 507
 		$countries = $this->checkout->action == 'process_reg_step' ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries();
509
-		if ( ! empty( $countries )) {
510
-			foreach( $countries as $country ){
511
-				if ( $country instanceof EE_Country ) {
512
-					$country_options[ $country->ID() ] = $country->name();
508
+		if ( ! empty($countries)) {
509
+			foreach ($countries as $country) {
510
+				if ($country instanceof EE_Country) {
511
+					$country_options[$country->ID()] = $country->name();
513 512
 				}
514 513
 			}
515 514
 		}
516
-		if( $question instanceof EE_Question 
517
-			&& $registration instanceof EE_Registration ) {
518
-			$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) );
515
+		if ($question instanceof EE_Question 
516
+			&& $registration instanceof EE_Registration) {
517
+			$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())));
519 518
 		} else {
520 519
 			$answer = EE_Answer::new_instance();
521 520
 		}
@@ -540,19 +539,19 @@  discard block
 block discarded – undo
540 539
 	 * @param EE_Registration $registration
541 540
 	 * @return array 2d keys are state IDs, values are their names
542 541
 	 */
543
-	public function use_cached_states_for_form_input( $states_list, $question, $registration, $answer ) {
544
-		$state_options = array( '' => array( '' => ''));
542
+	public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) {
543
+		$state_options = array('' => array('' => ''));
545 544
 		$states = $this->checkout->action == 'process_reg_step' ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_active_states();
546
-		if ( ! empty( $states )) {
547
-			foreach( $states as $state ){
548
-				if ( $state instanceof EE_State ) {
549
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
545
+		if ( ! empty($states)) {
546
+			foreach ($states as $state) {
547
+				if ($state instanceof EE_State) {
548
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
550 549
 				}
551 550
 			}
552 551
 		}
553
-		if( $question instanceof EE_Question 
554
-			&& $registration instanceof EE_Registration ) {
555
-			$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) );
552
+		if ($question instanceof EE_Question 
553
+			&& $registration instanceof EE_Registration) {
554
+			$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())));
556 555
 		} else {
557 556
 			$answer = EE_Answer::new_instance();
558 557
 		}
@@ -586,65 +585,65 @@  discard block
 block discarded – undo
586 585
 	 */
587 586
 	public function process_reg_step() {
588 587
 
589
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
588
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
590 589
 		// grab validated data from form
591 590
 		$valid_data = $this->checkout->current_step->valid_data();
592 591
 		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
593 592
 		//EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
594 593
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
595
-		if ( empty( $valid_data ))  {
596
-			EE_Error::add_error( __('No valid question responses were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
594
+		if (empty($valid_data)) {
595
+			EE_Error::add_error(__('No valid question responses were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
597 596
 			return FALSE;
598 597
 		}
599 598
 		//EEH_Debug_Tools::printr( $this->checkout->transaction, '$this->checkout->transaction', __FILE__, __LINE__ );
600
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
601
-			EE_Error::add_error( __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
599
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
600
+			EE_Error::add_error(__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
602 601
 			return FALSE;
603 602
 		}
604 603
 		// get cached registrations
605
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
604
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
606 605
 		// verify we got the goods
607
-		if ( empty( $registrations )) {
608
-			EE_Error::add_error( __( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
606
+		if (empty($registrations)) {
607
+			EE_Error::add_error(__('Your form data could not be applied to any valid registrations.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
609 608
 			return FALSE;
610 609
 		}
611 610
 		// extract attendee info from form data and save to model objects
612
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
611
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
613 612
 		// if first pass thru SPCO, then let's check processed registrations against the total number of tickets in the cart
614
-		if ( $registrations_processed === FALSE ) {
613
+		if ($registrations_processed === FALSE) {
615 614
 			// but return immediately if the previous step exited early due to errors
616 615
 			return FALSE;
617
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
616
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
618 617
 			// generate a correctly translated string for all possible singular/plural combinations
619
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
618
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
620 619
 				$error_msg = sprintf(
621
-					__( 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', 'event_espresso' ),
620
+					__('There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', 'event_espresso'),
622 621
 					$this->checkout->total_ticket_count,
623 622
 					$registrations_processed
624 623
 				);
625
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
624
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
626 625
 				$error_msg = sprintf(
627
-					__( 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', 'event_espresso' ),
626
+					__('There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', 'event_espresso'),
628 627
 					$this->checkout->total_ticket_count,
629 628
 					$registrations_processed
630 629
 				);
631 630
 			} else {
632 631
 				$error_msg = sprintf(
633
-					__( 'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed', 'event_espresso' ),
632
+					__('There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed', 'event_espresso'),
634 633
 					$this->checkout->total_ticket_count,
635 634
 					$registrations_processed
636 635
 				);
637 636
 
638 637
 			}
639
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
638
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
640 639
 			return FALSE;
641 640
 		}
642 641
 		// mark this reg step as completed
643 642
 		$this->set_completed();
644
-		$this->_set_success_message( __('The Attendee Information Step has been successfully completed.', 'event_espresso' ));
643
+		$this->_set_success_message(__('The Attendee Information Step has been successfully completed.', 'event_espresso'));
645 644
 		//do action in case a plugin wants to do something with the data submitted in step 1.
646 645
 		//passes EE_Single_Page_Checkout, and it's posted data
647
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
646
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
648 647
 		return TRUE;
649 648
 
650 649
 	}
@@ -658,9 +657,9 @@  discard block
 block discarded – undo
658 657
 	 * @param array             $valid_data
659 658
 	 * @return boolean | int
660 659
 	 */
661
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
660
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
662 661
 		// load resources and set some defaults
663
-		EE_Registry::instance()->load_model( 'Attendee' );
662
+		EE_Registry::instance()->load_model('Attendee');
664 663
 		// holder for primary registrant attendee object
665 664
 		$this->checkout->primary_attendee_obj = NULL;
666 665
 		// array for tracking reg form data for the primary registrant
@@ -677,19 +676,19 @@  discard block
 block discarded – undo
677 676
 		// attendee counter
678 677
 		$att_nmbr = 0;
679 678
 		// grab the saved registrations from the transaction
680
-		foreach ( $registrations  as $registration ) {
679
+		foreach ($registrations  as $registration) {
681 680
 			// verify EE_Registration object
682
-			if ( ! $registration instanceof EE_Registration ) {
683
-				EE_Error::add_error( __( 'An invalid Registration object was discovered when attempting to process your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
681
+			if ( ! $registration instanceof EE_Registration) {
682
+				EE_Error::add_error(__('An invalid Registration object was discovered when attempting to process your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
684 683
 				return FALSE;
685 684
 			}
686 685
 			$reg_url_link = $registration->reg_url_link();
687 686
 			// reg_url_link exists ?
688
-			if ( $reg_url_link ) {
687
+			if ($reg_url_link) {
689 688
 				// should this registration be processed during this visit ?
690
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
689
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
691 690
 					// if NOT revisiting, then let's save the registration now, so that we have a REG_ID to use when generating other objects
692
-					if ( ! $this->checkout->revisit ) {
691
+					if ( ! $this->checkout->revisit) {
693 692
 						$registration->save();
694 693
 					}
695 694
 
@@ -700,41 +699,41 @@  discard block
 block discarded – undo
700 699
 					 * @var bool   if TRUE is returned by the plugin then the
701 700
 					 *      		registration processing is halted.
702 701
 					 */
703
-					if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', FALSE, $att_nmbr, $registration, $registrations, $valid_data, $this ) ) {
702
+					if (apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', FALSE, $att_nmbr, $registration, $registrations, $valid_data, $this)) {
704 703
 						return FALSE;
705 704
 					}
706 705
 
707 706
 					// Houston, we have a registration!
708 707
 					$att_nmbr++;
709
-					$this->_attendee_data[ $reg_url_link ] = array();
708
+					$this->_attendee_data[$reg_url_link] = array();
710 709
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
711
-					if ( isset( $valid_data[ $reg_url_link ] )) {
710
+					if (isset($valid_data[$reg_url_link])) {
712 711
 						// do we need to copy basic info from primary attendee ?
713
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 ? TRUE : FALSE;
712
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 ? TRUE : FALSE;
714 713
 						// filter form input data for this registration
715
-						$valid_data[ $reg_url_link ] = apply_filters( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', $valid_data[ $reg_url_link ] );
714
+						$valid_data[$reg_url_link] = apply_filters('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', $valid_data[$reg_url_link]);
716 715
 						//EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
717
-						if ( isset( $valid_data['primary_attendee'] )) {
718
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] ) ? $valid_data['primary_attendee'] : FALSE;
719
-							unset( $valid_data['primary_attendee'] );
716
+						if (isset($valid_data['primary_attendee'])) {
717
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) ? $valid_data['primary_attendee'] : FALSE;
718
+							unset($valid_data['primary_attendee']);
720 719
 						}
721 720
 						// now loop through our array of valid post data && process attendee reg forms
722
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
723
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
724
-								foreach ( $form_inputs as $form_input => $input_value ) {
721
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
722
+							if ( ! in_array($form_section, $non_input_form_sections)) {
723
+								foreach ($form_inputs as $form_input => $input_value) {
725 724
 									// check for critical inputs
726
-									if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email( $form_input, $input_value )) {
725
+									if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email($form_input, $input_value)) {
727 726
 										return FALSE;
728 727
 									}
729 728
 									// store a bit of data about the primary attendee
730
-									if ( $att_nmbr == 1 && $reg_url_link == $primary_registrant['line_item_id'] && ! empty( $input_value )) {
731
-										$primary_registrant[ $form_input ] = $input_value;
732
-									} else if ( $copy_primary && isset( $primary_registrant[ $form_input ] ) && $input_value == NULL ) {
733
-										$input_value = $primary_registrant[ $form_input ];
729
+									if ($att_nmbr == 1 && $reg_url_link == $primary_registrant['line_item_id'] && ! empty($input_value)) {
730
+										$primary_registrant[$form_input] = $input_value;
731
+									} else if ($copy_primary && isset($primary_registrant[$form_input]) && $input_value == NULL) {
732
+										$input_value = $primary_registrant[$form_input];
734 733
 									}
735 734
 									// now attempt to save the input data
736
-									if ( ! $this->_save_registration_form_input( $registration, $form_input, $input_value ))  {
737
-										EE_Error::add_error( sprintf( __( 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', 'event_espresso' ), $form_input, $input_value ), __FILE__, __FUNCTION__, __LINE__ );
735
+									if ( ! $this->_save_registration_form_input($registration, $form_input, $input_value)) {
736
+										EE_Error::add_error(sprintf(__('Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', 'event_espresso'), $form_input, $input_value), __FILE__, __FUNCTION__, __LINE__);
738 737
 										return FALSE;
739 738
 									}
740 739
 								}
@@ -743,51 +742,51 @@  discard block
 block discarded – undo
743 742
 					}
744 743
 					//EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
745 744
 					// this registration does not require additional attendee information ?
746
-					if ( $copy_primary && $att_nmbr > 1 && $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
745
+					if ($copy_primary && $att_nmbr > 1 && $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
747 746
 						// just copy the primary registrant
748 747
 						$attendee = $this->checkout->primary_attendee_obj;
749 748
 					} else {
750 749
 						// have we met before?
751
-						$attendee = $this->_find_existing_attendee( $registration, $this->_attendee_data[ $reg_url_link ] );
750
+						$attendee = $this->_find_existing_attendee($registration, $this->_attendee_data[$reg_url_link]);
752 751
 						// did we find an already existing record for this attendee ?
753
-						if ( $attendee instanceof EE_Attendee ) {
754
-							$attendee = $this->_update_existing_attendee_data( $attendee, $this->_attendee_data[ $reg_url_link ] );
752
+						if ($attendee instanceof EE_Attendee) {
753
+							$attendee = $this->_update_existing_attendee_data($attendee, $this->_attendee_data[$reg_url_link]);
755 754
 						} else {
756 755
 							// ensure critical details are set for additional attendees
757
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 ? $this->_copy_critical_attendee_details_from_primary_registrant( $this->_attendee_data[ $reg_url_link ] ) : $this->_attendee_data[ $reg_url_link ];
758
-							$attendee = $this->_create_new_attendee( $registration, $this->_attendee_data[ $reg_url_link ] );
756
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1 ? $this->_copy_critical_attendee_details_from_primary_registrant($this->_attendee_data[$reg_url_link]) : $this->_attendee_data[$reg_url_link];
757
+							$attendee = $this->_create_new_attendee($registration, $this->_attendee_data[$reg_url_link]);
759 758
 						}
760 759
 						// who's #1 ?
761
-						if ( $att_nmbr == 1 ) {
760
+						if ($att_nmbr == 1) {
762 761
 							$this->checkout->primary_attendee_obj = $attendee;
763 762
 						}
764 763
 					}
765 764
 					//EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
766 765
 					// add relation to registration, set attendee ID, and cache attendee
767
-					$this->_associate_attendee_with_registration( $registration, $attendee );
768
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
769
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
766
+					$this->_associate_attendee_with_registration($registration, $attendee);
767
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
768
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
770 769
 						return FALSE;
771 770
 					}
772 771
 					/** @type EE_Registration_Processor $registration_processor */
773
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
772
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
774 773
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
775
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, FALSE );
774
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, FALSE);
776 775
 					/** @type EE_Transaction_Processor $transaction_processor */
777
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
776
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
778 777
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
779
-					$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
778
+					$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
780 779
 					// if we've gotten this far, then let's save what we have
781 780
 					$registration->save();
782 781
 					// add relation between TXN and registration
783
-					$this->_associate_registration_with_transaction( $registration );
782
+					$this->_associate_registration_with_transaction($registration);
784 783
 
785 784
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
786 785
 
787
-			}  else {
788
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
786
+			} else {
787
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
789 788
 				// remove malformed data
790
-				unset( $valid_data[ $reg_url_link ] );
789
+				unset($valid_data[$reg_url_link]);
791 790
 				return FALSE;
792 791
 			}
793 792
 
@@ -805,22 +804,22 @@  discard block
 block discarded – undo
805 804
 	 * @param string           	$input_value
806 805
 	 * @return boolean
807 806
 	 */
808
-	private function _save_registration_form_input( EE_Registration $registration, $form_input = '', $input_value = '' ) {
807
+	private function _save_registration_form_input(EE_Registration $registration, $form_input = '', $input_value = '') {
809 808
 		//echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '()</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b></h3>';
810 809
 		//EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
811 810
 		// allow for plugins to hook in and do their own processing of the form input.
812 811
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
813
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', FALSE, $registration, $form_input, $input_value, $this ) ) {
812
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', FALSE, $registration, $form_input, $input_value, $this)) {
814 813
 			return TRUE;
815 814
 		}
816 815
 
817 816
 		// grab related answer objects
818 817
 		$answers = $registration->answers();
819 818
 		// $answer_cache_id is the key used to find the EE_Answer we want
820
-		$answer_cache_id = $this->checkout->reg_url_link ? $form_input : $form_input . '-' . $registration->reg_url_link();
821
-		$answer_is_obj = isset( $answers[ $answer_cache_id ] ) && $answers[ $answer_cache_id ] instanceof EE_Answer ? TRUE : FALSE;
819
+		$answer_cache_id = $this->checkout->reg_url_link ? $form_input : $form_input.'-'.$registration->reg_url_link();
820
+		$answer_is_obj = isset($answers[$answer_cache_id]) && $answers[$answer_cache_id] instanceof EE_Answer ? TRUE : FALSE;
822 821
 		//rename form_inputs if they are EE_Attendee properties
823
-		switch( (string)$form_input ) {
822
+		switch ((string) $form_input) {
824 823
 
825 824
 			case 'state' :
826 825
 			case 'STA_ID' :
@@ -835,33 +834,33 @@  discard block
 block discarded – undo
835 834
 				break;
836 835
 
837 836
 			default :
838
-				$ATT_input = 'ATT_' . $form_input;
837
+				$ATT_input = 'ATT_'.$form_input;
839 838
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
840
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? TRUE : FALSE;
841
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
839
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? TRUE : FALSE;
840
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
842 841
 		}
843 842
 		//EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
844 843
 		//EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
845 844
 		//EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
846 845
 		//EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
847 846
 		// if this form input has a corresponding attendee property
848
-		if ( $attendee_property ) {
849
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
850
-			if (  $answer_is_obj ) {
847
+		if ($attendee_property) {
848
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
849
+			if ($answer_is_obj) {
851 850
 				// and delete the corresponding answer since we won't be storing this data in that object
852
-				$registration->_remove_relation_to( $answers[ $answer_cache_id ], 'Answer' );
853
-				$answers[ $answer_cache_id ]->delete_permanently();
851
+				$registration->_remove_relation_to($answers[$answer_cache_id], 'Answer');
852
+				$answers[$answer_cache_id]->delete_permanently();
854 853
 			}
855 854
 			return TRUE;
856
-		} elseif ( $answer_is_obj ) {
855
+		} elseif ($answer_is_obj) {
857 856
 			// save this data to the answer object
858
-			$answers[ $answer_cache_id ]->set_value( $input_value );
859
-			$result = $answers[ $answer_cache_id ]->save();
857
+			$answers[$answer_cache_id]->set_value($input_value);
858
+			$result = $answers[$answer_cache_id]->save();
860 859
 			return $result !== false ? true : false;
861 860
 		} else {
862
-			foreach ( $answers as $answer ) {
863
-				if ( $answer instanceof EE_Answer && $answer->question_ID() == $answer_cache_id ) {
864
-					$answer->set_value( $input_value );
861
+			foreach ($answers as $answer) {
862
+				if ($answer instanceof EE_Answer && $answer->question_ID() == $answer_cache_id) {
863
+					$answer->set_value($input_value);
865 864
 					$result = $answer->save();
866 865
 					return $result !== false ? true : false;
867 866
 				}
@@ -879,33 +878,33 @@  discard block
 block discarded – undo
879 878
 	 * @param string $input_value
880 879
 	 * @return boolean
881 880
 	 */
882
-	private function _verify_critical_attendee_details_are_set_and_validate_email( $form_input = '', $input_value = '' ) {
883
-		if ( empty( $input_value )) {
881
+	private function _verify_critical_attendee_details_are_set_and_validate_email($form_input = '', $input_value = '') {
882
+		if (empty($input_value)) {
884 883
 			// if the form input isn't marked as being required, then just return
885
-			if ( ! isset( $this->_required_questions[ $form_input ]  ) || ! $this->_required_questions[ $form_input ] ) {
884
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
886 885
 				return true;
887 886
 			}
888
-			switch( $form_input ) {
887
+			switch ($form_input) {
889 888
 				case 'fname' :
890
-					EE_Error::add_error( __( 'First Name is a required value.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
889
+					EE_Error::add_error(__('First Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
891 890
 					return FALSE;
892 891
 					break;
893 892
 				case 'lname' :
894
-					EE_Error::add_error( __( 'Last Name is a required value.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
893
+					EE_Error::add_error(__('Last Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
895 894
 					return FALSE;
896 895
 					break;
897 896
 				case 'email' :
898
-					EE_Error::add_error( __( 'Email Address is a required value.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
897
+					EE_Error::add_error(__('Email Address is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
899 898
 					return FALSE;
900 899
 					break;
901 900
 			}
902
-		} else if ( $form_input === 'email' ) {
901
+		} else if ($form_input === 'email') {
903 902
 			// clean the email address
904
-			$valid_email = sanitize_email( $input_value );
903
+			$valid_email = sanitize_email($input_value);
905 904
 			// check if it matches
906
-			if ( $input_value != $valid_email ) {
905
+			if ($input_value != $valid_email) {
907 906
 				// whoops!!!
908
-				EE_Error::add_error( __( 'Please enter a valid email address.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
907
+				EE_Error::add_error(__('Please enter a valid email address.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
909 908
 				return FALSE;
910 909
 			}
911 910
 		}
@@ -933,14 +932,14 @@  discard block
 block discarded – undo
933 932
 	 * @param array           $attendee_data
934 933
 	 * @return boolean
935 934
 	 */
936
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
935
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
937 936
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
938
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : '';
939
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : '';
940
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] ) ? $attendee_data['ATT_email'] : '';
937
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : '';
938
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : '';
939
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email']) ? $attendee_data['ATT_email'] : '';
941 940
 		// but only if those have values
942
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
943
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
941
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
942
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
944 943
 				'ATT_fname' => $ATT_fname,
945 944
 				'ATT_lname' => $ATT_lname,
946 945
 				'ATT_email' => $ATT_email
@@ -948,7 +947,7 @@  discard block
 block discarded – undo
948 947
 		} else {
949 948
 			$existing_attendee = NULL;
950 949
 		}
951
-		return apply_filters( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', $existing_attendee, $registration, $attendee_data );
950
+		return apply_filters('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', $existing_attendee, $registration, $attendee_data);
952 951
 	}
953 952
 
954 953
 
@@ -960,13 +959,13 @@  discard block
 block discarded – undo
960 959
 	 * @param array           $attendee_data
961 960
 	 * @return \EE_Attendee
962 961
 	 */
963
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
962
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
964 963
 		// first remove fname, lname, and email from attendee data
965
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
964
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
966 965
 		// now loop thru what's left and add to attendee CPT
967
-		foreach ( $attendee_data as $property_name => $property_value ) {
968
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
969
-				$existing_attendee->set( $property_name, $property_value );
966
+		foreach ($attendee_data as $property_name => $property_value) {
967
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
968
+				$existing_attendee->set($property_name, $property_value);
970 969
 			}
971 970
 		}
972 971
 		// better save that now
@@ -983,11 +982,11 @@  discard block
 block discarded – undo
983 982
 	 * @param EE_Attendee     $attendee
984 983
 	 * @return void
985 984
 	 */
986
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
985
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
987 986
 		// add relation to attendee
988
-		$registration->_add_relation_to( $attendee, 'Attendee' );
989
-		$registration->set_attendee_id( $attendee->ID() );
990
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
987
+		$registration->_add_relation_to($attendee, 'Attendee');
988
+		$registration->set_attendee_id($attendee->ID());
989
+		$registration->update_cache_after_object_save('Attendee', $attendee);
991 990
 	}
992 991
 
993 992
 
@@ -998,10 +997,10 @@  discard block
 block discarded – undo
998 997
 	 * @param EE_Registration $registration
999 998
 	 * @return void
1000 999
 	 */
1001
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1000
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1002 1001
 		// add relation to attendee
1003
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1004
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1002
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1003
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1005 1004
 	}
1006 1005
 
1007 1006
 
@@ -1013,17 +1012,17 @@  discard block
 block discarded – undo
1013 1012
 	 * @param array $attendee_data
1014 1013
 	 * @return array
1015 1014
 	 */
1016
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1015
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1017 1016
 		// bare minimum critical details include first name, last name, email address
1018
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1017
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1019 1018
 		// add address info to critical details?
1020
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', FALSE )) {
1021
-			$address_details = array( 'ATT_address', 'ATT_address2', 'ATT_city', 'STA_ID', 'CNT_ISO', 'ATT_zip', 'ATT_phone' );
1022
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1019
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', FALSE)) {
1020
+			$address_details = array('ATT_address', 'ATT_address2', 'ATT_city', 'STA_ID', 'CNT_ISO', 'ATT_zip', 'ATT_phone');
1021
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1023 1022
 		}
1024
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1025
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) || empty( $attendee_data[ $critical_attendee_detail ] )) {
1026
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( $critical_attendee_detail );
1023
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1024
+			if ( ! isset($attendee_data[$critical_attendee_detail]) || empty($attendee_data[$critical_attendee_detail])) {
1025
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get($critical_attendee_detail);
1027 1026
 			}
1028 1027
 		}
1029 1028
 		return $attendee_data;
@@ -1038,11 +1037,11 @@  discard block
 block discarded – undo
1038 1037
 	 * @param array           $attendee_data
1039 1038
 	 * @return \EE_Attendee
1040 1039
 	 */
1041
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1040
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1042 1041
 		// create new attendee object
1043
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1042
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1044 1043
 		// set author to event creator
1045
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1044
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1046 1045
 		$new_attendee->save();
1047 1046
 		return $new_attendee;
1048 1047
 	}
@@ -1058,7 +1057,7 @@  discard block
 block discarded – undo
1058 1057
 	 */
1059 1058
 	public function update_reg_step() {
1060 1059
 		// save everything
1061
-		if ( $this->process_reg_step() ) {
1060
+		if ($this->process_reg_step()) {
1062 1061
 			$this->checkout->redirect = TRUE;
1063 1062
 			$this->checkout->redirect_url = add_query_arg(
1064 1063
 				array(
@@ -1067,7 +1066,7 @@  discard block
 block discarded – undo
1067 1066
 				),
1068 1067
 				$this->checkout->thank_you_page_url
1069 1068
 			);
1070
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1069
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1071 1070
 			return TRUE;
1072 1071
 		}
1073 1072
 		return FALSE;
Please login to merge, or discard this patch.
core/helpers/EEH_Line_Item.helper.php 2 patches
Spacing   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  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')) { exit('No direct script access allowed'); }
2 2
 /**
3 3
  *
4 4
  * EEH_Line_Item
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	 * @param boolean $code if set to a value, ensures there is only one line item with that code
41 41
 	 * @return boolean success
42 42
 	 */
43
-	public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL  ){
44
-		$items_subtotal = self::get_pre_tax_subtotal( $parent_line_item );
43
+	public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) {
44
+		$items_subtotal = self::get_pre_tax_subtotal($parent_line_item);
45 45
 		$line_item = EE_Line_Item::new_instance(array(
46 46
 			'LIN_name' => $name,
47 47
 			'LIN_desc' => $description,
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 			'LIN_quantity' => $quantity,
50 50
 			'LIN_percent' => null,
51 51
 			'LIN_is_taxable' => $taxable,
52
-			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
53
-			'LIN_total' => floatval( $unit_price ) * intval( $quantity ),
52
+			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
53
+			'LIN_total' => floatval($unit_price) * intval($quantity),
54 54
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
55 55
 			'LIN_code' => $code,
56 56
 		));
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			$line_item,
60 60
 			$parent_line_item
61 61
 		);
62
-		return self::add_item( $parent_line_item, $line_item );
62
+		return self::add_item($parent_line_item, $line_item);
63 63
 	}
64 64
 
65 65
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param boolean      $taxable
81 81
 	 * @return boolean success
82 82
 	 */
83
-	public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){
83
+	public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) {
84 84
 		$line_item = EE_Line_Item::new_instance(array(
85 85
 			'LIN_name' => $name,
86 86
 			'LIN_desc' => $description,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			'LIN_percent' => $percentage_amount,
89 89
 			'LIN_quantity' => NULL,
90 90
 			'LIN_is_taxable' => $taxable,
91
-			'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )),
91
+			'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)),
92 92
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
93 93
 			'LIN_parent' => $parent_line_item->ID()
94 94
 		));
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			'FHEE__EEH_Line_Item__add_percentage_based_item__line_item',
97 97
 			$line_item
98 98
 		);
99
-		return self::add_item( $parent_line_item, $line_item );
99
+		return self::add_item($parent_line_item, $line_item);
100 100
 	}
101 101
 
102 102
 
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
 	 * @return \EE_Line_Item
118 118
 	 * @throws \EE_Error
119 119
 	 */
120
-	public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){
121
-		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) {
122
-			throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) );
120
+	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
121
+		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) {
122
+			throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID()));
123 123
 		}
124 124
 		// either increment the qty for an existing ticket
125
-		$line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty );
125
+		$line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty);
126 126
 		// or add a new one
127
-		if ( ! $line_item instanceof EE_Line_Item ) {
128
-			$line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty );
127
+		if ( ! $line_item instanceof EE_Line_Item) {
128
+			$line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty);
129 129
 		}
130 130
 		$total_line_item->recalculate_total_including_taxes();
131 131
 		return $line_item;
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 	 * @return \EE_Line_Item
142 142
 	 * @throws \EE_Error
143 143
 	 */
144
-	public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
144
+	public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
145 145
 		$line_item = null;
146
-		if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) {
147
-			$ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item );
148
-			foreach ( (array)$ticket_line_items as $ticket_line_item ) {
149
-				if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) {
146
+		if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) {
147
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
148
+			foreach ((array) $ticket_line_items as $ticket_line_item) {
149
+				if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) {
150 150
 					$line_item = $ticket_line_item;
151 151
 					break;
152 152
 				}
153 153
 			}
154 154
 		}
155
-		if ( $line_item instanceof EE_Line_Item ) {
156
-			EEH_Line_Item::increment_quantity( $line_item, $qty );
155
+		if ($line_item instanceof EE_Line_Item) {
156
+			EEH_Line_Item::increment_quantity($line_item, $qty);
157 157
 			return $line_item;
158 158
 		}
159 159
 		return null;
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 	 * @param int $qty
167 167
 	 * @return void
168 168
 	 */
169
-	public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) {
170
-		if( ! $line_item->is_percent() ) {
169
+	public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) {
170
+		if ( ! $line_item->is_percent()) {
171 171
 			$qty += $line_item->quantity();
172
-			$line_item->set_quantity( $qty );
173
-			$line_item->set_total( $line_item->unit_price() * $qty );
172
+			$line_item->set_quantity($qty);
173
+			$line_item->set_total($line_item->unit_price() * $qty);
174 174
 		}
175
-		foreach( $line_item->children() as $child ) {
176
-			if( $child->is_sub_line_item() ) {
177
-				EEH_Line_Item::update_quantity( $child, $line_item->quantity() );
175
+		foreach ($line_item->children() as $child) {
176
+			if ($child->is_sub_line_item()) {
177
+				EEH_Line_Item::update_quantity($child, $line_item->quantity());
178 178
 			}
179 179
 		}
180 180
 	}
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
 	 * @param EE_Line_Item $line_item
186 186
 	 * @param int $new_quantity
187 187
 	 */
188
-	public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) {
189
-		if( ! $line_item->is_percent() ) {
190
-			$line_item->set_quantity( $new_quantity );
191
-			$line_item->set_total( $line_item->unit_price() * $new_quantity );
188
+	public static function update_quantity(EE_Line_Item $line_item, $new_quantity) {
189
+		if ( ! $line_item->is_percent()) {
190
+			$line_item->set_quantity($new_quantity);
191
+			$line_item->set_total($line_item->unit_price() * $new_quantity);
192 192
 		}
193
-		foreach( $line_item->children() as $child ) {
194
-			if( $child->is_sub_line_item() ) {
195
-				EEH_Line_Item::update_quantity( $child, $new_quantity );
193
+		foreach ($line_item->children() as $child) {
194
+			if ($child->is_sub_line_item()) {
195
+				EEH_Line_Item::update_quantity($child, $new_quantity);
196 196
 			}
197 197
 		}
198 198
 	}
@@ -207,45 +207,45 @@  discard block
 block discarded – undo
207 207
 	 * @return \EE_Line_Item
208 208
 	 * @throws \EE_Error
209 209
 	 */
210
-	public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
210
+	public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
211 211
 		$datetimes = $ticket->datetimes();
212
-		$first_datetime = reset( $datetimes );
213
-		if( $first_datetime instanceof EE_Datetime &&
214
-				$first_datetime->event() instanceof EE_Event ) {
212
+		$first_datetime = reset($datetimes);
213
+		if ($first_datetime instanceof EE_Datetime &&
214
+				$first_datetime->event() instanceof EE_Event) {
215 215
 			$first_datetime_name = $first_datetime->event()->name();
216 216
 		} else {
217
-			$first_datetime_name = __( 'Event', 'event_espresso' );
217
+			$first_datetime_name = __('Event', 'event_espresso');
218 218
 		}
219
-		$event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name );
219
+		$event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name);
220 220
 		// get event subtotal line
221
-		$events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket );
222
-		if ( ! $events_sub_total instanceof EE_Line_Item ) {
223
-			throw new EE_Error( sprintf( __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) );
221
+		$events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket);
222
+		if ( ! $events_sub_total instanceof EE_Line_Item) {
223
+			throw new EE_Error(sprintf(__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), $ticket->ID(), $total_line_item->ID()));
224 224
 		}
225 225
 		// add $ticket to cart
226
-		$line_item = EE_Line_Item::new_instance( array(
226
+		$line_item = EE_Line_Item::new_instance(array(
227 227
 			'LIN_name'       	=> $ticket->name(),
228
-			'LIN_desc'       		=> $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event,
228
+			'LIN_desc'       		=> $ticket->description() != '' ? $ticket->description().' '.$event : $event,
229 229
 			'LIN_unit_price' 	=> $ticket->price(),
230 230
 			'LIN_quantity'   	=> $qty,
231 231
 			'LIN_is_taxable' 	=> $ticket->taxable(),
232
-			'LIN_order'      	=> count( $events_sub_total->children() ),
232
+			'LIN_order'      	=> count($events_sub_total->children()),
233 233
 			'LIN_total'      		=> $ticket->price() * $qty,
234 234
 			'LIN_type'       		=> EEM_Line_Item::type_line_item,
235 235
 			'OBJ_ID'         		=> $ticket->ID(),
236 236
 			'OBJ_type'       	=> 'Ticket'
237
-		) );
237
+		));
238 238
 		$line_item = apply_filters(
239 239
 			'FHEE__EEH_Line_Item__create_ticket_line_item__line_item',
240 240
 			$line_item
241 241
 		);
242
-		$events_sub_total->add_child_line_item( $line_item );
242
+		$events_sub_total->add_child_line_item($line_item);
243 243
 		//now add the sub-line items
244 244
 		$running_total_for_ticket = 0;
245
-		foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) {
245
+		foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) {
246 246
 			$sign = $price->is_discount() ? -1 : 1;
247 247
 			$price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty;
248
-			$sub_line_item = EE_Line_Item::new_instance( array(
248
+			$sub_line_item = EE_Line_Item::new_instance(array(
249 249
 				'LIN_name'       	=> $price->name(),
250 250
 				'LIN_desc'       		=> $price->desc(),
251 251
 				'LIN_quantity'   	=> $price->is_percent() ? null : $qty,
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 				'LIN_type'       		=> EEM_Line_Item::type_sub_line_item,
256 256
 				'OBJ_ID'         		=> $price->ID(),
257 257
 				'OBJ_type'       	=> 'Price'
258
-			) );
258
+			));
259 259
 			$sub_line_item = apply_filters(
260 260
 				'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item',
261 261
 				$sub_line_item
262 262
 			);
263
-			if ( $price->is_percent() ) {
264
-				$sub_line_item->set_percent( $sign * $price->amount() );
263
+			if ($price->is_percent()) {
264
+				$sub_line_item->set_percent($sign * $price->amount());
265 265
 			} else {
266
-				$sub_line_item->set_unit_price( $sign * $price->amount() );
266
+				$sub_line_item->set_unit_price($sign * $price->amount());
267 267
 			}
268 268
 			$running_total_for_ticket += $price_total;
269
-			$line_item->add_child_line_item( $sub_line_item );
269
+			$line_item->add_child_line_item($sub_line_item);
270 270
 		}
271 271
 		return $line_item;
272 272
 	}
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 	 * @param EE_Line_Item $item to be added
285 285
 	 * @return boolean
286 286
 	 */
287
-	public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){
288
-		$pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item );
289
-		if ( $pre_tax_subtotal instanceof EE_Line_Item ){
287
+	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) {
288
+		$pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item);
289
+		if ($pre_tax_subtotal instanceof EE_Line_Item) {
290 290
 			$success = $pre_tax_subtotal->add_child_line_item($item);
291
-		}else{
291
+		} else {
292 292
 			return FALSE;
293 293
 		}
294 294
 		$total_line_item->recalculate_total_including_taxes();
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
303 303
 	 *	@return \EE_Line_Item
304 304
 	 */
305
-	public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){
306
-		$pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' );
307
-		return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item );
305
+	public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) {
306
+		$pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal');
307
+		return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item);
308 308
 	}
309 309
 
310 310
 
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
315 315
 	 * @return \EE_Line_Item
316 316
 	 */
317
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){
318
-		$taxes = $total_line_item->get_child_line_item( 'taxes' );
319
-		return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item );
317
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item) {
318
+		$taxes = $total_line_item->get_child_line_item('taxes');
319
+		return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item);
320 320
 	}
321 321
 
322 322
 
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Transaction $transaction
328 328
 	 * @return void
329 329
 	 */
330
-	public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){
331
-		if( $transaction ){
330
+	public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) {
331
+		if ($transaction) {
332 332
 			/** @type EEM_Transaction $EEM_Transaction */
333
-			$EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' );
334
-			$transaction = $EEM_Transaction->ensure_is_ID( $transaction );
335
-			$line_item->set_TXN_ID( $transaction );
333
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
334
+			$transaction = $EEM_Transaction->ensure_is_ID($transaction);
335
+			$line_item->set_TXN_ID($transaction);
336 336
 		}
337 337
 	}
338 338
 
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @param EE_Transaction $transaction
346 346
 	 * @return \EE_Line_Item of type total
347 347
 	 */
348
-	public static function create_total_line_item( $transaction = NULL ){
349
-		$total_line_item = EE_Line_Item::new_instance( array(
348
+	public static function create_total_line_item($transaction = NULL) {
349
+		$total_line_item = EE_Line_Item::new_instance(array(
350 350
 			'LIN_code'	=> 'total',
351 351
 			'LIN_name'	=> __('Grand Total', 'event_espresso'),
352 352
 			'LIN_type'	=> EEM_Line_Item::type_total,
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 			'FHEE__EEH_Line_Item__create_total_line_item__total_line_item',
357 357
 			$total_line_item
358 358
 		);
359
-		self::set_TXN_ID( $total_line_item, $transaction );
360
-		self::create_pre_tax_subtotal( $total_line_item, $transaction );
361
-		self::create_taxes_subtotal( $total_line_item, $transaction );
359
+		self::set_TXN_ID($total_line_item, $transaction);
360
+		self::create_pre_tax_subtotal($total_line_item, $transaction);
361
+		self::create_taxes_subtotal($total_line_item, $transaction);
362 362
 		return $total_line_item;
363 363
 	}
364 364
 
@@ -370,19 +370,19 @@  discard block
 block discarded – undo
370 370
 	 * @param EE_Transaction $transaction
371 371
 	 * @return EE_Line_Item
372 372
 	 */
373
-	protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
374
-		$pre_tax_line_item = EE_Line_Item::new_instance( array(
373
+	protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
374
+		$pre_tax_line_item = EE_Line_Item::new_instance(array(
375 375
 			'LIN_code' 	=> 'pre-tax-subtotal',
376
-			'LIN_name' 	=> __( 'Pre-Tax Subtotal', 'event_espresso' ),
376
+			'LIN_name' 	=> __('Pre-Tax Subtotal', 'event_espresso'),
377 377
 			'LIN_type' 	=> EEM_Line_Item::type_sub_total
378
-		) );
378
+		));
379 379
 		$pre_tax_line_item = apply_filters(
380 380
 			'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item',
381 381
 			$pre_tax_line_item
382 382
 		);
383
-		self::set_TXN_ID( $pre_tax_line_item, $transaction );
384
-		$total_line_item->add_child_line_item( $pre_tax_line_item );
385
-		self::create_event_subtotal( $pre_tax_line_item, $transaction );
383
+		self::set_TXN_ID($pre_tax_line_item, $transaction);
384
+		$total_line_item->add_child_line_item($pre_tax_line_item);
385
+		self::create_event_subtotal($pre_tax_line_item, $transaction);
386 386
 		return $pre_tax_line_item;
387 387
 	}
388 388
 
@@ -395,21 +395,21 @@  discard block
 block discarded – undo
395 395
 	 * @param EE_Transaction $transaction
396 396
 	 * @return EE_Line_Item
397 397
 	 */
398
-	protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
398
+	protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
399 399
 		$tax_line_item = EE_Line_Item::new_instance(array(
400 400
 			'LIN_code'	=> 'taxes',
401 401
 			'LIN_name' 	=> __('Taxes', 'event_espresso'),
402 402
 			'LIN_type'	=> EEM_Line_Item::type_tax_sub_total,
403
-			'LIN_order' => 1000,//this should always come last
403
+			'LIN_order' => 1000, //this should always come last
404 404
 		));
405 405
 		$tax_line_item = apply_filters(
406 406
 			'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item',
407 407
 			$tax_line_item
408 408
 		);
409
-		self::set_TXN_ID( $tax_line_item, $transaction );
410
-		$total_line_item->add_child_line_item( $tax_line_item );
409
+		self::set_TXN_ID($tax_line_item, $transaction);
410
+		$total_line_item->add_child_line_item($tax_line_item);
411 411
 		//and lastly, add the actual taxes
412
-		self::apply_taxes( $total_line_item );
412
+		self::apply_taxes($total_line_item);
413 413
 		return $tax_line_item;
414 414
 	}
415 415
 
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	 * @param EE_Event $event
423 423
 	 * @return EE_Line_Item
424 424
 	 */
425
-	public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){
425
+	public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) {
426 426
 		$event_line_item = EE_Line_Item::new_instance(array(
427
-			'LIN_code'	=> self::get_event_code( $event ),
428
-			'LIN_name' 	=> self::get_event_name( $event ),
429
-			'LIN_desc' 	=> self::get_event_desc( $event ),
427
+			'LIN_code'	=> self::get_event_code($event),
428
+			'LIN_name' 	=> self::get_event_name($event),
429
+			'LIN_desc' 	=> self::get_event_desc($event),
430 430
 			'LIN_type'	=> EEM_Line_Item::type_sub_total,
431 431
 			'OBJ_type' 	=> 'Event',
432 432
 			'OBJ_ID' 		=>  $event instanceof EE_Event ? $event->ID() : 0
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 			'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item',
436 436
 			$event_line_item
437 437
 		);
438
-		self::set_TXN_ID( $event_line_item, $transaction );
439
-		$pre_tax_line_item->add_child_line_item( $event_line_item );
438
+		self::set_TXN_ID($event_line_item, $transaction);
439
+		$pre_tax_line_item->add_child_line_item($event_line_item);
440 440
 		return $event_line_item;
441 441
 	}
442 442
 
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 * @param EE_Event $event
446 446
 	 * @return string
447 447
 	 */
448
-	public static function get_event_code( $event ) {
449
-		return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' );
448
+	public static function get_event_code($event) {
449
+		return 'event-'.($event instanceof EE_Event ? $event->ID() : '0');
450 450
 	}
451 451
 
452 452
 	/**
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @param EE_Event $event
455 455
 	 * @return string
456 456
 	 */
457
-	public static function get_event_name( $event ) {
458
-		return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' );
457
+	public static function get_event_name($event) {
458
+		return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso');
459 459
 	}
460 460
 
461 461
 	/**
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 	 * @param EE_Event $event
464 464
 	 * @return string
465 465
 	 */
466
-	public static function get_event_desc( $event ) {
466
+	public static function get_event_desc($event) {
467 467
 		return $event instanceof EE_Event ? $event->short_description() : '';
468 468
 	}
469 469
 
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
 	  * @throws \EE_Error
478 478
 	  * @return EE_Line_Item
479 479
 	  */
480
-	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
480
+	public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) {
481 481
 		$first_datetime = $ticket->first_datetime();
482
-		if( ! $first_datetime instanceof EE_Datetime ){
483
-			throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) );
482
+		if ( ! $first_datetime instanceof EE_Datetime) {
483
+			throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID()));
484 484
 		}
485 485
 		$event = $first_datetime->event();
486
-		if ( ! $event instanceof EE_Event ) {
487
-			throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) );
486
+		if ( ! $event instanceof EE_Event) {
487
+			throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID()));
488 488
 		}
489
-		return EEH_Line_Item::get_event_line_item( $grand_total, $event );
489
+		return EEH_Line_Item::get_event_line_item($grand_total, $event);
490 490
 	}
491 491
 
492 492
 	/**
@@ -495,31 +495,31 @@  discard block
 block discarded – undo
495 495
 	 * @param EE_Event $event
496 496
 	 * @return EE_Line_Item for the event subtotal which is a child of $grand_total
497 497
 	 */
498
-	public static function get_event_line_item( EE_Line_Item $grand_total, $event ) {
498
+	public static function get_event_line_item(EE_Line_Item $grand_total, $event) {
499 499
 		/** @type EE_Event $event */
500
-		$event = EEM_Event::instance()->ensure_is_obj( $event, true );
500
+		$event = EEM_Event::instance()->ensure_is_obj($event, true);
501 501
 		$event_line_item = NULL;
502 502
 		$found = false;
503
-		foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) {
503
+		foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) {
504 504
 			// default event subtotal, we should only ever find this the first time this method is called
505
-			if ( ! $event_line_item->OBJ_ID() ) {
505
+			if ( ! $event_line_item->OBJ_ID()) {
506 506
 				// let's use this! but first... set the event details
507
-				EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
507
+				EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
508 508
 				$found = true;
509 509
 				break;
510
-			} else if ( $event_line_item->OBJ_ID() === $event->ID() ) {
510
+			} else if ($event_line_item->OBJ_ID() === $event->ID()) {
511 511
 				// found existing line item for this event in the cart, so break out of loop and use this one
512 512
 				$found = true;
513 513
 				break;
514 514
 			}
515 515
 		}
516
-		if ( ! $found ) {
516
+		if ( ! $found) {
517 517
 			//there is no event sub-total yet, so add it
518
-			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total );
518
+			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total);
519 519
 			// create a new "event" subtotal below that
520
-			$event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event );
520
+			$event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event);
521 521
 			// and set the event details
522
-			EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
522
+			EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
523 523
 		}
524 524
 		return $event_line_item;
525 525
 	}
@@ -533,14 +533,14 @@  discard block
 block discarded – undo
533 533
 	 * @param EE_Transaction $transaction
534 534
 	 * @return EE_Line_Item
535 535
 	 */
536
-	public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){
537
-		if ( $event instanceof EE_Event ) {
538
-			$event_line_item->set_code( self::get_event_code( $event ) );
539
-			$event_line_item->set_name( self::get_event_name( $event ) );
540
-			$event_line_item->set_desc( self::get_event_desc( $event ) );
541
-			$event_line_item->set_OBJ_ID( $event->ID() );
536
+	public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) {
537
+		if ($event instanceof EE_Event) {
538
+			$event_line_item->set_code(self::get_event_code($event));
539
+			$event_line_item->set_name(self::get_event_name($event));
540
+			$event_line_item->set_desc(self::get_event_desc($event));
541
+			$event_line_item->set_OBJ_ID($event->ID());
542 542
 		}
543
-		self::set_TXN_ID( $event_line_item, $transaction );
543
+		self::set_TXN_ID($event_line_item, $transaction);
544 544
 	}
545 545
 
546 546
 
@@ -551,19 +551,19 @@  discard block
 block discarded – undo
551 551
 	 * any old taxes are removed
552 552
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
553 553
 	 */
554
-	public static function apply_taxes( EE_Line_Item $total_line_item ){
554
+	public static function apply_taxes(EE_Line_Item $total_line_item) {
555 555
 		/** @type EEM_Price $EEM_Price */
556
-		$EEM_Price = EE_Registry::instance()->load_model( 'Price' );
556
+		$EEM_Price = EE_Registry::instance()->load_model('Price');
557 557
 		// get array of taxes via Price Model
558 558
 		$ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes();
559
-		ksort( $ordered_taxes );
560
-		$taxes_line_item = self::get_taxes_subtotal( $total_line_item );
559
+		ksort($ordered_taxes);
560
+		$taxes_line_item = self::get_taxes_subtotal($total_line_item);
561 561
 		//just to be safe, remove its old tax line items
562 562
 		$taxes_line_item->delete_children_line_items();
563 563
 		//loop thru taxes
564
-		foreach ( $ordered_taxes as $order => $taxes ) {
565
-			foreach ( $taxes as $tax ) {
566
-				if ( $tax instanceof EE_Price ) {
564
+		foreach ($ordered_taxes as $order => $taxes) {
565
+			foreach ($taxes as $tax) {
566
+				if ($tax instanceof EE_Price) {
567 567
 					$tax_line_item = EE_Line_Item::new_instance(
568 568
 						array(
569 569
 							'LIN_name'       => $tax->name(),
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 						'FHEE__EEH_Line_Item__apply_taxes__tax_line_item',
582 582
 						$tax_line_item
583 583
 					);
584
-					$taxes_line_item->add_child_line_item( $tax_line_item );
584
+					$taxes_line_item->add_child_line_item($tax_line_item);
585 585
 				}
586 586
 			}
587 587
 		}
@@ -596,10 +596,10 @@  discard block
 block discarded – undo
596 596
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
597 597
 	 * @return float
598 598
 	 */
599
-	public static function ensure_taxes_applied( $total_line_item ){
600
-		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
601
-		if( ! $taxes_subtotal->children()){
602
-			self::apply_taxes( $total_line_item );
599
+	public static function ensure_taxes_applied($total_line_item) {
600
+		$taxes_subtotal = self::get_taxes_subtotal($total_line_item);
601
+		if ( ! $taxes_subtotal->children()) {
602
+			self::apply_taxes($total_line_item);
603 603
 		}
604 604
 		return $taxes_subtotal->total();
605 605
 	}
@@ -612,16 +612,16 @@  discard block
 block discarded – undo
612 612
 	 * @param EE_Line_Item $parent_line_item
613 613
 	 * @return bool
614 614
 	 */
615
-	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
615
+	public static function delete_all_child_items(EE_Line_Item $parent_line_item) {
616 616
 		$deleted = 0;
617
-		foreach ( $parent_line_item->children() as $child_line_item ) {
618
-			if ( $child_line_item instanceof EE_Line_Item ) {
619
-				$deleted += EEH_Line_Item::delete_all_child_items( $child_line_item );
620
-				if ( $child_line_item->ID() ) {
617
+		foreach ($parent_line_item->children() as $child_line_item) {
618
+			if ($child_line_item instanceof EE_Line_Item) {
619
+				$deleted += EEH_Line_Item::delete_all_child_items($child_line_item);
620
+				if ($child_line_item->ID()) {
621 621
 					$child_line_item->delete();
622
-					unset( $child_line_item );
622
+					unset($child_line_item);
623 623
 				} else {
624
-					$parent_line_item->delete_child_line_item( $child_line_item->code() );
624
+					$parent_line_item->delete_child_line_item($child_line_item->code());
625 625
 				}
626 626
 				$deleted++;
627 627
 			}
@@ -643,25 +643,25 @@  discard block
 block discarded – undo
643 643
 	 * @param array|bool|string $line_item_codes
644 644
 	 * @return int number of items successfully removed
645 645
 	 */
646
-	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
646
+	public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) {
647 647
 
648
-		if( $total_line_item->type() != EEM_Line_Item::type_total ){
649
-			EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __( 'This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso' ), '4.6.18' );
648
+		if ($total_line_item->type() != EEM_Line_Item::type_total) {
649
+			EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18');
650 650
 		}
651
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
651
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
652 652
 
653 653
 		// check if only a single line_item_id was passed
654
-		if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) {
654
+		if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) {
655 655
 			// place single line_item_id in an array to appear as multiple line_item_ids
656
-			$line_item_codes = array ( $line_item_codes );
656
+			$line_item_codes = array($line_item_codes);
657 657
 		}
658 658
 		$removals = 0;
659 659
 		// cycle thru line_item_ids
660
-		foreach ( $line_item_codes as $line_item_id ) {
660
+		foreach ($line_item_codes as $line_item_id) {
661 661
 			$removals += $total_line_item->delete_child_line_item($line_item_id);
662 662
 		}
663 663
 
664
-		if ( $removals > 0 ) {
664
+		if ($removals > 0) {
665 665
 			$total_line_item->recalculate_taxes_and_tax_total();
666 666
 			return $removals;
667 667
 		} else {
@@ -684,32 +684,32 @@  discard block
 block discarded – undo
684 684
 	 *                                           $amount will be added onto it; otherwise will simply set the taxes to match $amount
685 685
 	 * @return EE_Line_Item the new tax line item created
686 686
 	 */
687
-	public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){
688
-            $tax_subtotal = self::get_taxes_subtotal( $total_line_item );
687
+	public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false) {
688
+            $tax_subtotal = self::get_taxes_subtotal($total_line_item);
689 689
             $taxable_total = $total_line_item->taxable_total();
690 690
 
691
-            if( $add_to_existing_line_item ) {
692
-                $new_tax = $tax_subtotal->get_child_line_item( $code );
693
-                EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) );
691
+            if ($add_to_existing_line_item) {
692
+                $new_tax = $tax_subtotal->get_child_line_item($code);
693
+                EEM_Line_Item::instance()->delete(array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID())));
694 694
             } else {
695 695
                 $new_tax = null;
696 696
                 $tax_subtotal->delete_children_line_items();
697 697
             }
698
-            if( $new_tax ) {
699
-                $new_tax->set_total( $new_tax->total() + $amount );
700
-                $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 );
698
+            if ($new_tax) {
699
+                $new_tax->set_total($new_tax->total() + $amount);
700
+                $new_tax->set_percent($taxable_total ? ($new_tax->total()) / $taxable_total * 100 : 0);
701 701
             } else {
702 702
                 //no existing tax item. Create it
703
-				$new_tax = EE_Line_Item::new_instance( array(
703
+				$new_tax = EE_Line_Item::new_instance(array(
704 704
 					'TXN_ID'      => $total_line_item->TXN_ID(),
705
-					'LIN_name'    => $name ? $name : __( 'Tax', 'event_espresso' ),
705
+					'LIN_name'    => $name ? $name : __('Tax', 'event_espresso'),
706 706
 					'LIN_desc'    => $description ? $description : '',
707
-					'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0,
707
+					'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0,
708 708
 					'LIN_total'   => $amount,
709 709
 					'LIN_parent'  => $tax_subtotal->ID(),
710 710
 					'LIN_type'    => EEM_Line_Item::type_tax,
711 711
 					'LIN_code'    => $code
712
-				) );
712
+				));
713 713
 			}
714 714
 
715 715
             $new_tax = apply_filters(
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 				$total_line_item
719 719
             );
720 720
             $new_tax->save();
721
-            $tax_subtotal->set_total( $new_tax->total() );
721
+            $tax_subtotal->set_total($new_tax->total());
722 722
             $tax_subtotal->save();
723 723
             $total_line_item->recalculate_total_including_taxes();
724 724
             return $new_tax;
@@ -734,17 +734,17 @@  discard block
 block discarded – undo
734 734
 	 *  it will be whitelisted (ie, except from becoming taxable)
735 735
 	 * @param boolean $taxable
736 736
 	 */
737
-	public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ) {
738
-		if( $code_substring_for_whitelist !== null ) {
739
-			$whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false;
737
+	public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null) {
738
+		if ($code_substring_for_whitelist !== null) {
739
+			$whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false;
740 740
 		} else {
741 741
 			$whitelisted = false;
742 742
 		}
743
-		if( $line_item->is_line_item() && ! $whitelisted ) {
744
-			$line_item->set_is_taxable( $taxable );
743
+		if ($line_item->is_line_item() && ! $whitelisted) {
744
+			$line_item->set_is_taxable($taxable);
745 745
 		}
746
-		foreach( $line_item->children() as $child_line_item ) {
747
-			EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist );
746
+		foreach ($line_item->children() as $child_line_item) {
747
+			EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist);
748 748
 		}
749 749
 	}
750 750
 
@@ -757,8 +757,8 @@  discard block
 block discarded – undo
757 757
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
758 758
 	 * @return EE_Line_Item[]
759 759
 	 */
760
-	public static function get_event_subtotals( EE_Line_Item $parent_line_item ) {
761
-		return self::get_subtotals_of_object_type( $parent_line_item, 'Event' );
760
+	public static function get_event_subtotals(EE_Line_Item $parent_line_item) {
761
+		return self::get_subtotals_of_object_type($parent_line_item, 'Event');
762 762
 	}
763 763
 
764 764
 
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
 	 * @param string $obj_type
772 772
 	 * @return EE_Line_Item[]
773 773
 	 */
774
-	public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
775
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type );
774
+	public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
775
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type);
776 776
 	}
777 777
 
778 778
 
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
785 785
 	 * @return EE_Line_Item[]
786 786
 	 */
787
-	public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) {
788
-		return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' );
787
+	public static function get_ticket_line_items(EE_Line_Item $parent_line_item) {
788
+		return self::get_line_items_of_object_type($parent_line_item, 'Ticket');
789 789
 	}
790 790
 
791 791
 
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
 	 * @param string $obj_type
799 799
 	 * @return EE_Line_Item[]
800 800
 	 */
801
-	public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
802
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type );
801
+	public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
802
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type);
803 803
 	}
804 804
 
805 805
 
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
811 811
 	 * @return EE_Line_Item[]
812 812
 	 */
813
-	public static function get_tax_descendants( EE_Line_Item $parent_line_item ) {
814
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax );
813
+	public static function get_tax_descendants(EE_Line_Item $parent_line_item) {
814
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax);
815 815
 	}
816 816
 
817 817
 
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
823 823
 	 * @return EE_Line_Item[]
824 824
 	 */
825
-	public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) {
826
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item );
825
+	public static function get_line_item_descendants(EE_Line_Item $parent_line_item) {
826
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item);
827 827
 	}
828 828
 
829 829
 
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	 * @param string $line_item_type one of the EEM_Line_Item constants
837 837
 	 * @return EE_Line_Item[]
838 838
 	 */
839
-	public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) {
840
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL );
839
+	public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) {
840
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL);
841 841
 	}
842 842
 
843 843
 
@@ -850,15 +850,15 @@  discard block
 block discarded – undo
850 850
 	 * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching
851 851
 	 * @return EE_Line_Item[]
852 852
 	 */
853
-	protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) {
853
+	protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) {
854 854
 		$objects = array();
855
-		foreach ( $parent_line_item->children() as $child_line_item ) {
856
-			if ( $child_line_item instanceof EE_Line_Item ) {
857
-				if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) {
855
+		foreach ($parent_line_item->children() as $child_line_item) {
856
+			if ($child_line_item instanceof EE_Line_Item) {
857
+				if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) {
858 858
 					$objects[] = $child_line_item;
859 859
 				} else {
860 860
 					//go-through-all-its children looking for more matches
861
-					$objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type ));
861
+					$objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type));
862 862
 				}
863 863
 			}
864 864
 		}
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 * @param array $OBJ_IDs array of OBJ_IDs
877 877
 	 * @return EE_Line_Item[]
878 878
 	 */
879
-	public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) {
880
-		return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs );
879
+	public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) {
880
+		return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs);
881 881
 	}
882 882
 
883 883
 
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 	 * @param array $OBJ_IDs array of OBJ_IDs
891 891
 	 * @return EE_Line_Item[]
892 892
 	 */
893
-	protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) {
893
+	protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) {
894 894
 		$objects = array();
895
-		foreach ( $parent_line_item->children() as $child_line_item ) {
896
-			if ( $child_line_item instanceof EE_Line_Item ) {
897
-				if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) {
895
+		foreach ($parent_line_item->children() as $child_line_item) {
896
+			if ($child_line_item instanceof EE_Line_Item) {
897
+				if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) {
898 898
 					$objects[] = $child_line_item;
899 899
 				} else {
900 900
 					//go-through-all-its children looking for more matches
901
-					$objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs ));
901
+					$objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs));
902 902
 				}
903 903
 			}
904 904
 		}
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 	 * @param string $type like one of the EEM_Line_Item::type_*
917 917
 	 * @return EE_Line_Item
918 918
 	 */
919
-	public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) {
920
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type );
919
+	public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) {
920
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type);
921 921
 	}
922 922
 
923 923
 
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 	 * @param string $code any value used for LIN_code
931 931
 	 * @return EE_Line_Item
932 932
 	 */
933
-	public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) {
934
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code );
933
+	public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) {
934
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code);
935 935
 	}
936 936
 
937 937
 
@@ -944,15 +944,15 @@  discard block
 block discarded – undo
944 944
 	 * @param string $value any value stored in $search_field
945 945
 	 * @return EE_Line_Item
946 946
 	 */
947
-	protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) {
948
-		foreach( $parent_line_item->children() as $child ){
949
-			if ( $child->get( $search_field ) == $value ){
947
+	protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) {
948
+		foreach ($parent_line_item->children() as $child) {
949
+			if ($child->get($search_field) == $value) {
950 950
 				return $child;
951 951
 			}
952 952
 		}
953
-		foreach( $parent_line_item->children() as $child ){
954
-			$descendant_found = self::_get_nearest_descendant( $child, $search_field, $value );
955
-			if ( $descendant_found ){
953
+		foreach ($parent_line_item->children() as $child) {
954
+			$descendant_found = self::_get_nearest_descendant($child, $search_field, $value);
955
+			if ($descendant_found) {
956 956
 				return $descendant_found;
957 957
 			}
958 958
 		}
@@ -968,22 +968,22 @@  discard block
 block discarded – undo
968 968
 	 * @param int $indentation
969 969
 	 * @return void
970 970
 	 */
971
-	public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){
971
+	public static function visualize(EE_Line_Item $line_item, $indentation = 0) {
972 972
 		echo "\n<br />";
973
-		for( $i = 0; $i < $indentation; $i++ ){
973
+		for ($i = 0; $i < $indentation; $i++) {
974 974
 			echo " - ";
975 975
 		}
976
-		if( $line_item->is_percent() ) {
977
-			$breakdown = $line_item->percent() . '%';
976
+		if ($line_item->is_percent()) {
977
+			$breakdown = $line_item->percent().'%';
978 978
 		} else {
979
-			$breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity();
979
+			$breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity();
980 980
 		}
981
-		echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")";
982
-		if( $line_item->is_taxable() ){
981
+		echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")";
982
+		if ($line_item->is_taxable()) {
983 983
 			echo "  * taxable";
984 984
 		}
985
-		if( $line_item->children() ){
986
-			foreach($line_item->children() as $child){
985
+		if ($line_item->children()) {
986
+			foreach ($line_item->children() as $child) {
987 987
 				self::visualize($child, $indentation + 1);
988 988
 			}
989 989
 		}
@@ -1024,88 +1024,88 @@  discard block
 block discarded – undo
1024 1024
 	 *                                          is theirs, which can be done with
1025 1025
 	 *                                          `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );`
1026 1026
 	 */
1027
-	public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) {
1027
+	public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) {
1028 1028
 		//init running grand total if not already
1029
-		if ( ! isset( $running_totals[ 'total' ] ) ) {
1030
-			$running_totals[ 'total' ] = 0;
1029
+		if ( ! isset($running_totals['total'])) {
1030
+			$running_totals['total'] = 0;
1031 1031
 		}
1032
-		if( ! isset( $running_totals[ 'taxable' ] ) ) {
1033
-			$running_totals[ 'taxable' ] = array( 'total' => 0 );
1032
+		if ( ! isset($running_totals['taxable'])) {
1033
+			$running_totals['taxable'] = array('total' => 0);
1034 1034
 		}
1035
-		foreach ( $line_item->children() as $child_line_item ) {
1036
-			switch ( $child_line_item->type() ) {
1035
+		foreach ($line_item->children() as $child_line_item) {
1036
+			switch ($child_line_item->type()) {
1037 1037
 
1038 1038
 				case EEM_Line_Item::type_sub_total :
1039
-					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities );
1039
+					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities);
1040 1040
 					//combine arrays but preserve numeric keys
1041
-					$running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals );
1042
-					$running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ];
1043
-					$running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ];
1041
+					$running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals);
1042
+					$running_totals['total'] += $running_totals_from_subtotal['total'];
1043
+					$running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total'];
1044 1044
 					break;
1045 1045
 
1046 1046
 				case EEM_Line_Item::type_tax_sub_total :
1047 1047
 
1048 1048
 					//find how much the taxes percentage is
1049
-					if ( $child_line_item->percent() != 0 ) {
1049
+					if ($child_line_item->percent() != 0) {
1050 1050
 						$tax_percent_decimal = $child_line_item->percent() / 100;
1051 1051
 					} else {
1052 1052
 						$tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100;
1053 1053
 					}
1054 1054
 					//and apply to all the taxable totals, and add to the pretax totals
1055
-					foreach ( $running_totals as $line_item_id => $this_running_total ) {
1055
+					foreach ($running_totals as $line_item_id => $this_running_total) {
1056 1056
 						//"total" and "taxable" array key is an exception
1057
-						if ( $line_item_id === 'taxable' ) {
1057
+						if ($line_item_id === 'taxable') {
1058 1058
 							continue;
1059 1059
 						}
1060
-						$taxable_total = $running_totals[ 'taxable' ][ $line_item_id ];
1061
-						$running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal );
1060
+						$taxable_total = $running_totals['taxable'][$line_item_id];
1061
+						$running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal);
1062 1062
 					}
1063 1063
 					break;
1064 1064
 
1065 1065
 				case EEM_Line_Item::type_line_item :
1066 1066
 
1067 1067
 					// ticket line items or ????
1068
-					if ( $child_line_item->OBJ_type() === 'Ticket' ) {
1068
+					if ($child_line_item->OBJ_type() === 'Ticket') {
1069 1069
 						// kk it's a ticket
1070
-						if ( isset( $running_totals[ $child_line_item->ID() ] ) ) {
1070
+						if (isset($running_totals[$child_line_item->ID()])) {
1071 1071
 							//huh? that shouldn't happen.
1072
-							$running_totals[ 'total' ] += $child_line_item->total();
1072
+							$running_totals['total'] += $child_line_item->total();
1073 1073
 						} else {
1074 1074
 							//its not in our running totals yet. great.
1075
-							if ( $child_line_item->is_taxable() ) {
1075
+							if ($child_line_item->is_taxable()) {
1076 1076
 								$taxable_amount = $child_line_item->unit_price();
1077 1077
 							} else {
1078 1078
 								$taxable_amount = 0;
1079 1079
 							}
1080 1080
 							// are we only calculating totals for some tickets?
1081
-							if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) {
1082
-								$quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ];
1083
-								$running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0;
1084
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0;
1081
+							if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) {
1082
+								$quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()];
1083
+								$running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0;
1084
+								$running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0;
1085 1085
 							} else {
1086 1086
 								$quantity = $child_line_item->quantity();
1087
-								$running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price();
1088
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount;
1087
+								$running_totals[$child_line_item->ID()] = $child_line_item->unit_price();
1088
+								$running_totals['taxable'][$child_line_item->ID()] = $taxable_amount;
1089 1089
 							}
1090
-							$running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity;
1091
-							$running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity;
1090
+							$running_totals['taxable']['total'] += $taxable_amount * $quantity;
1091
+							$running_totals['total'] += $child_line_item->unit_price() * $quantity;
1092 1092
 						}
1093 1093
 					} else {
1094 1094
 						// it's some other type of item added to the cart
1095 1095
 						// it should affect the running totals
1096 1096
 						// basically we want to convert it into a PERCENT modifier. Because
1097 1097
 						// more clearly affect all registration's final price equally
1098
-						$line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1;
1099
-						foreach ( $running_totals as $line_item_id => $this_running_total ) {
1098
+						$line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1;
1099
+						foreach ($running_totals as $line_item_id => $this_running_total) {
1100 1100
 							//the "taxable" array key is an exception
1101
-							if ( $line_item_id === 'taxable' ) {
1101
+							if ($line_item_id === 'taxable') {
1102 1102
 								continue;
1103 1103
 							}
1104 1104
 							// update the running totals
1105 1105
 							// yes this actually even works for the running grand total!
1106
-							$running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total;
1107
-							if ( $child_line_item->is_taxable() ) {
1108
-								$running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ];
1106
+							$running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total;
1107
+							if ($child_line_item->is_taxable()) {
1108
+								$running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id];
1109 1109
 							}
1110 1110
 						}
1111 1111
 					}
@@ -1124,15 +1124,15 @@  discard block
 block discarded – undo
1124 1124
 	 * @param EE_Registration[] $registrations
1125 1125
 	 * @return \EE_Line_Item
1126 1126
 	 */
1127
-	public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) {
1128
-		$copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations );
1129
-		foreach ( $line_item->children() as $child_li ) {
1130
-			$copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) );
1127
+	public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) {
1128
+		$copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations);
1129
+		foreach ($line_item->children() as $child_li) {
1130
+			$copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations));
1131 1131
 		}
1132 1132
 		//if this is the grand total line item, make sure the totals all add up
1133 1133
 		//(we could have duplicated this logic AS we copied the line items, but
1134 1134
 		//it seems DRYer this way)
1135
-		if ( $copy_li->type() === EEM_Line_Item::type_total ) {
1135
+		if ($copy_li->type() === EEM_Line_Item::type_total) {
1136 1136
 			$copy_li->recalculate_total_including_taxes();
1137 1137
 		}
1138 1138
 		return $copy_li;
@@ -1147,26 +1147,26 @@  discard block
 block discarded – undo
1147 1147
 	 * @return EE_Line_Item
1148 1148
 	 * @param EE_Registration[] $registrations
1149 1149
 	 */
1150
-	public static function billable_line_item( EE_Line_Item $line_item, $registrations ) {
1150
+	public static function billable_line_item(EE_Line_Item $line_item, $registrations) {
1151 1151
 		$new_li_fields = $line_item->model_field_array();
1152
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1152
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1153 1153
 			$line_item->OBJ_type() === 'Ticket'
1154 1154
 		) {
1155 1155
 			$count = 0;
1156
-			foreach ( $registrations as $registration ) {
1157
-				if ( $line_item->OBJ_ID() === $registration->ticket_ID() &&
1158
-					in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() )
1156
+			foreach ($registrations as $registration) {
1157
+				if ($line_item->OBJ_ID() === $registration->ticket_ID() &&
1158
+					in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment())
1159 1159
 				) {
1160 1160
 					$count++;
1161 1161
 				}
1162 1162
 			}
1163
-			$new_li_fields[ 'LIN_quantity' ] = $count;
1163
+			$new_li_fields['LIN_quantity'] = $count;
1164 1164
 		}
1165 1165
 		//don't set the total. We'll leave that up to the code that calculates it
1166
-		unset( $new_li_fields[ 'LIN_ID' ] );
1167
-		unset( $new_li_fields[ 'LIN_parent' ] );
1168
-		unset( $new_li_fields[ 'LIN_total' ] );
1169
-		return EE_Line_Item::new_instance( $new_li_fields );
1166
+		unset($new_li_fields['LIN_ID']);
1167
+		unset($new_li_fields['LIN_parent']);
1168
+		unset($new_li_fields['LIN_total']);
1169
+		return EE_Line_Item::new_instance($new_li_fields);
1170 1170
 	}
1171 1171
 
1172 1172
 
@@ -1178,19 +1178,19 @@  discard block
 block discarded – undo
1178 1178
 	 * @param EE_Line_Item $line_item |null
1179 1179
 	 * @return \EE_Line_Item|null
1180 1180
 	 */
1181
-	public static function non_empty_line_items( EE_Line_Item $line_item ) {
1182
-		$copied_li = EEH_Line_Item::non_empty_line_item( $line_item );
1183
-		if ( $copied_li === null ) {
1181
+	public static function non_empty_line_items(EE_Line_Item $line_item) {
1182
+		$copied_li = EEH_Line_Item::non_empty_line_item($line_item);
1183
+		if ($copied_li === null) {
1184 1184
 			return null;
1185 1185
 		}
1186 1186
 		//if this is an event subtotal, we want to only include it if it
1187 1187
 		//has a non-zero total and at least one ticket line item child
1188 1188
 		$ticket_children = 0;
1189
-		foreach ( $line_item->children() as $child_li ) {
1190
-			$child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li );
1191
-			if ( $child_li_copy !== null ) {
1192
-				$copied_li->add_child_line_item( $child_li_copy );
1193
-				if ( $child_li_copy->type() === EEM_Line_Item::type_line_item &&
1189
+		foreach ($line_item->children() as $child_li) {
1190
+			$child_li_copy = EEH_Line_Item::non_empty_line_items($child_li);
1191
+			if ($child_li_copy !== null) {
1192
+				$copied_li->add_child_line_item($child_li_copy);
1193
+				if ($child_li_copy->type() === EEM_Line_Item::type_line_item &&
1194 1194
 					$child_li_copy->OBJ_type() === 'Ticket'
1195 1195
 				) {
1196 1196
 					$ticket_children++;
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		}
1200 1200
 		//if this is an event subtotal with NO ticket children
1201 1201
 		//we basically want to ignore it
1202
-		if ( $line_item->type() === EEM_Line_Item::type_sub_total &&
1202
+		if ($line_item->type() === EEM_Line_Item::type_sub_total &&
1203 1203
 			$line_item->OBJ_type() === 'Event' &&
1204 1204
 			$ticket_children === 0 &&
1205 1205
 			$line_item->total() === 0
@@ -1217,8 +1217,8 @@  discard block
 block discarded – undo
1217 1217
 	 * @param EE_Line_Item      $line_item
1218 1218
 	 * @return EE_Line_Item
1219 1219
 	 */
1220
-	public static function non_empty_line_item( EE_Line_Item $line_item ) {
1221
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1220
+	public static function non_empty_line_item(EE_Line_Item $line_item) {
1221
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1222 1222
 			$line_item->OBJ_type() === 'Ticket' &&
1223 1223
 			$line_item->quantity() == 0
1224 1224
 		) {
@@ -1226,9 +1226,9 @@  discard block
 block discarded – undo
1226 1226
 		}
1227 1227
 		$new_li_fields = $line_item->model_field_array();
1228 1228
 		//don't set the total. We'll leave that up to the code that calculates it
1229
-		unset( $new_li_fields[ 'LIN_ID' ] );
1230
-		unset( $new_li_fields[ 'LIN_parent' ] );
1231
-		return EE_Line_Item::new_instance( $new_li_fields );
1229
+		unset($new_li_fields['LIN_ID']);
1230
+		unset($new_li_fields['LIN_parent']);
1231
+		return EE_Line_Item::new_instance($new_li_fields);
1232 1232
 	}
1233 1233
 
1234 1234
 
@@ -1242,9 +1242,9 @@  discard block
 block discarded – undo
1242 1242
 	 * @param EE_Line_Item $total_line_item
1243 1243
 	 *	@return \EE_Line_Item
1244 1244
 	 */
1245
-	public static function get_items_subtotal( EE_Line_Item $total_line_item ){
1246
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' );
1247
-		return self::get_pre_tax_subtotal( $total_line_item );
1245
+	public static function get_items_subtotal(EE_Line_Item $total_line_item) {
1246
+		EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0');
1247
+		return self::get_pre_tax_subtotal($total_line_item);
1248 1248
 	}
1249 1249
 
1250 1250
 
@@ -1254,9 +1254,9 @@  discard block
 block discarded – undo
1254 1254
 	 * @param EE_Transaction $transaction
1255 1255
 	 *	@return \EE_Line_Item
1256 1256
 	 */
1257
-	public static function create_default_total_line_item( $transaction = NULL) {
1258
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' );
1259
-		return self::create_total_line_item( $transaction );
1257
+	public static function create_default_total_line_item($transaction = NULL) {
1258
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0');
1259
+		return self::create_total_line_item($transaction);
1260 1260
 	}
1261 1261
 
1262 1262
 
@@ -1267,9 +1267,9 @@  discard block
 block discarded – undo
1267 1267
 	 * @param EE_Transaction $transaction
1268 1268
 	 *	@return \EE_Line_Item
1269 1269
 	 */
1270
-	public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1271
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' );
1272
-		return self::create_pre_tax_subtotal( $total_line_item, $transaction );
1270
+	public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1271
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0');
1272
+		return self::create_pre_tax_subtotal($total_line_item, $transaction);
1273 1273
 	}
1274 1274
 
1275 1275
 
@@ -1280,9 +1280,9 @@  discard block
 block discarded – undo
1280 1280
 	 * @param EE_Transaction $transaction
1281 1281
 	 *	@return \EE_Line_Item
1282 1282
 	 */
1283
-	public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1284
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' );
1285
-		return self::create_taxes_subtotal( $total_line_item, $transaction );
1283
+	public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1284
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0');
1285
+		return self::create_taxes_subtotal($total_line_item, $transaction);
1286 1286
 	}
1287 1287
 
1288 1288
 
@@ -1293,9 +1293,9 @@  discard block
 block discarded – undo
1293 1293
 	 * @param EE_Transaction $transaction
1294 1294
 	 *	@return \EE_Line_Item
1295 1295
 	 */
1296
-	public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1297
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' );
1298
-		return self::create_event_subtotal( $total_line_item, $transaction );
1296
+	public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1297
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0');
1298
+		return self::create_event_subtotal($total_line_item, $transaction);
1299 1299
 	}
1300 1300
 
1301 1301
 
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -468,15 +468,15 @@  discard block
 block discarded – undo
468 468
 	}
469 469
 
470 470
 	/**
471
-	  * Given the grand total line item and a ticket, finds the event sub-total
472
-	  * line item the ticket's purchase should be added onto
473
-	  *
474
-	  * @access public
475
-	  * @param EE_Line_Item $grand_total the grand total line item
476
-	  * @param EE_Ticket $ticket
477
-	  * @throws \EE_Error
478
-	  * @return EE_Line_Item
479
-	  */
471
+	 * Given the grand total line item and a ticket, finds the event sub-total
472
+	 * line item the ticket's purchase should be added onto
473
+	 *
474
+	 * @access public
475
+	 * @param EE_Line_Item $grand_total the grand total line item
476
+	 * @param EE_Ticket $ticket
477
+	 * @throws \EE_Error
478
+	 * @return EE_Line_Item
479
+	 */
480 480
 	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
481 481
 		$first_datetime = $ticket->first_datetime();
482 482
 		if( ! $first_datetime instanceof EE_Datetime ){
@@ -685,21 +685,21 @@  discard block
 block discarded – undo
685 685
 	 * @return EE_Line_Item the new tax line item created
686 686
 	 */
687 687
 	public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){
688
-            $tax_subtotal = self::get_taxes_subtotal( $total_line_item );
689
-            $taxable_total = $total_line_item->taxable_total();
690
-
691
-            if( $add_to_existing_line_item ) {
692
-                $new_tax = $tax_subtotal->get_child_line_item( $code );
693
-                EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) );
694
-            } else {
695
-                $new_tax = null;
696
-                $tax_subtotal->delete_children_line_items();
697
-            }
698
-            if( $new_tax ) {
699
-                $new_tax->set_total( $new_tax->total() + $amount );
700
-                $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 );
701
-            } else {
702
-                //no existing tax item. Create it
688
+			$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
689
+			$taxable_total = $total_line_item->taxable_total();
690
+
691
+			if( $add_to_existing_line_item ) {
692
+				$new_tax = $tax_subtotal->get_child_line_item( $code );
693
+				EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) );
694
+			} else {
695
+				$new_tax = null;
696
+				$tax_subtotal->delete_children_line_items();
697
+			}
698
+			if( $new_tax ) {
699
+				$new_tax->set_total( $new_tax->total() + $amount );
700
+				$new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 );
701
+			} else {
702
+				//no existing tax item. Create it
703 703
 				$new_tax = EE_Line_Item::new_instance( array(
704 704
 					'TXN_ID'      => $total_line_item->TXN_ID(),
705 705
 					'LIN_name'    => $name ? $name : __( 'Tax', 'event_espresso' ),
@@ -712,16 +712,16 @@  discard block
 block discarded – undo
712 712
 				) );
713 713
 			}
714 714
 
715
-            $new_tax = apply_filters(
715
+			$new_tax = apply_filters(
716 716
 				'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal',
717 717
 				$new_tax,
718 718
 				$total_line_item
719
-            );
720
-            $new_tax->save();
721
-            $tax_subtotal->set_total( $new_tax->total() );
722
-            $tax_subtotal->save();
723
-            $total_line_item->recalculate_total_including_taxes();
724
-            return $new_tax;
719
+			);
720
+			$new_tax->save();
721
+			$tax_subtotal->set_total( $new_tax->total() );
722
+			$tax_subtotal->save();
723
+			$total_line_item->recalculate_total_including_taxes();
724
+			return $new_tax;
725 725
 	}
726 726
 
727 727
 
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_Paypal_Standard_Form.form.php 1 patch
Spacing   +38 added lines, -38 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
 /**
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
 	/**
22 22
 	 * @param EE_PMT_Paypal_Standard $payment_method_type
23 23
 	 */
24
-	public function __construct( $payment_method_type ){
24
+	public function __construct($payment_method_type) {
25 25
 		parent::__construct(
26 26
 			array(
27 27
 				'payment_method_type'          => $payment_method_type,
28 28
 				'extra_meta_inputs'            => array(
29
-					'paypal_id'        => new EE_Text_Input( array(
30
-						'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
31
-						'html_help_text'  => __( "Typically [email protected]", 'event_espresso' ),
29
+					'paypal_id'        => new EE_Text_Input(array(
30
+						'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
31
+						'html_help_text'  => __("Typically [email protected]", 'event_espresso'),
32 32
 						'required'        => true
33
-					) ),
34
-					'image_url'        => new EE_Admin_File_Uploader_Input( array(
35
-						'html_help_text'  => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ),
36
-						'html_label_text' => __( 'Image URL', 'event_espresso' )
37
-					) ),
38
-					'paypal_taxes'     => new EE_Yes_No_Input( array(
39
-						'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
40
-						'html_help_text'  => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ),
33
+					)),
34
+					'image_url'        => new EE_Admin_File_Uploader_Input(array(
35
+						'html_help_text'  => __("Used for your business/personal logo on the PayPal page", 'event_espresso'),
36
+						'html_label_text' => __('Image URL', 'event_espresso')
37
+					)),
38
+					'paypal_taxes'     => new EE_Yes_No_Input(array(
39
+						'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
40
+						'html_help_text'  => __('Whether Paypal should add taxes to the order', 'event_espresso'),
41 41
 						'default'         => false
42
-					) ),
43
-					'paypal_shipping'  => new EE_Yes_No_Input( array(
44
-						'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
45
-						'html_help_text'  => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ),
42
+					)),
43
+					'paypal_shipping'  => new EE_Yes_No_Input(array(
44
+						'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
45
+						'html_help_text'  => __('Whether Paypal should add shipping surcharges', 'event_espresso'),
46 46
 						'default'         => false
47
-					) ),
48
-					'shipping_details' => new EE_Select_Input( array(
49
-						EE_PMT_Paypal_Standard::shipping_info_none     => __( "Do not prompt for an address", 'event_espresso' ),
50
-						EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ),
51
-						EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' )
52
-					) ),
47
+					)),
48
+					'shipping_details' => new EE_Select_Input(array(
49
+						EE_PMT_Paypal_Standard::shipping_info_none     => __("Do not prompt for an address", 'event_espresso'),
50
+						EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'),
51
+						EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso')
52
+					)),
53 53
 				),
54
-				'before_form_content_template' => $payment_method_type->file_folder() . DS . 'templates' . DS . 'paypal_standard_settings_before_form.template.php',
54
+				'before_form_content_template' => $payment_method_type->file_folder().DS.'templates'.DS.'paypal_standard_settings_before_form.template.php',
55 55
 			)
56 56
 		);
57 57
 	}
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * @param array $req_data
63 63
 	 */
64
-	protected function _normalize( $req_data ) {
65
-		parent::_normalize( $req_data );
66
-		$paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' );
67
-		$paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' );
68
-		$paypal_requests_address_info = $this->get_input_value( 'shipping_details' );
64
+	protected function _normalize($req_data) {
65
+		parent::_normalize($req_data);
66
+		$paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
67
+		$paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68
+		$paypal_requests_address_info = $this->get_input_value('shipping_details');
69 69
 		if (
70
-			( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
70
+			($paypal_calculates_shipping || $paypal_calculates_taxes) &&
71 71
 			$paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
72 72
 		) {
73 73
 			//they want paypal to calculate taxes or shipping. They need to ask for
74 74
 			//address info, otherwise paypal can't calculate taxes or shipping
75 75
 			/** @type EE_Select_Input $shipping_details_input */
76
-			$shipping_details_input = $this->get_input( 'shipping_details' );
77
-			$shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional );
76
+			$shipping_details_input = $this->get_input('shipping_details');
77
+			$shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
78 78
 			$shipping_details_input_options = $shipping_details_input->options();
79 79
 			EE_Error::add_attention(
80 80
 				sprintf(
81
-					__( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ),
82
-					strip_tags( $shipping_details_input->html_label_text() ),
83
-					isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] )
84
-						? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
85
-						: __( 'Unknown', 'event_espresso' )
81
+					__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
82
+					strip_tags($shipping_details_input->html_label_text()),
83
+					isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional])
84
+						? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]
85
+						: __('Unknown', 'event_espresso')
86 86
 				),
87 87
 				__FILE__, __FUNCTION__, __LINE__
88 88
 			);
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 3 patches
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		parent::set_settings($settings_array);
78 78
 		if($this->_debug_mode){
79 79
 			$this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
80
-		}else{
80
+		} else{
81 81
 			$this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr';
82 82
 		}
83 83
 	}
@@ -340,8 +340,9 @@  discard block
 block discarded – undo
340 340
 		$update_info = array();
341 341
 		foreach ( $raw_post_array as $keyval ) {
342 342
 			$keyval = explode( '=', $keyval );
343
-			if ( count( $keyval ) == 2 )
344
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
343
+			if ( count( $keyval ) == 2 ) {
344
+							$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
345
+			}
345 346
 		}
346 347
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
347 348
 		$req = 'cmd=_notify-validate';
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -456,16 +456,16 @@
 block discarded – undo
456 456
 
457 457
 		//might paypal have changed the taxes?
458 458
 		if( $this->_paypal_taxes && $payment_was_itemized ){
459
-                    //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
460
-                    $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
461
-                    $this->_line_item->set_total_tax_to(
462
-                            $transaction->total_line_item(),
463
-                            floatval( $update_info['tax'] ),
464
-                            __( 'Taxes', 'event_espresso' ),
465
-                            __( 'Calculated by Paypal', 'event_espresso' ),
466
-                            'paypal_tax'
467
-                    );
468
-                    $grand_total_needs_resaving = TRUE;
459
+					//note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
460
+					$this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
461
+					$this->_line_item->set_total_tax_to(
462
+							$transaction->total_line_item(),
463
+							floatval( $update_info['tax'] ),
464
+							__( 'Taxes', 'event_espresso' ),
465
+							__( 'Calculated by Paypal', 'event_espresso' ),
466
+							'paypal_tax'
467
+					);
468
+					$grand_total_needs_resaving = TRUE;
469 469
 		}
470 470
 
471 471
 		$shipping_amount = floatval( $update_info[ 'mc_shipping' ] );
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return EEG_Paypal_Standard
69 69
 	 */
70 70
 	public function __construct() {
71
-		$this->set_uses_separate_IPN_request( true ) ;
71
+		$this->set_uses_separate_IPN_request(true);
72 72
 		parent::__construct();
73 73
 	}
74 74
 
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
79 79
 	 * @param array $settings_array
80 80
 	 */
81
-	public function set_settings($settings_array){
81
+	public function set_settings($settings_array) {
82 82
 		parent::set_settings($settings_array);
83
-		if($this->_debug_mode){
83
+		if ($this->_debug_mode) {
84 84
 			$this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
85
-		}else{
85
+		} else {
86 86
 			$this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr';
87 87
 		}
88 88
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param string      $cancel_url   URL to send the user to after a cancelled payment attempt on teh payment provider's website
98 98
 	 * @return EEI_Payment
99 99
 	 */
100
-	public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){
100
+	public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) {
101 101
 		$redirect_args = array();
102 102
 		$transaction = $payment->transaction();
103 103
 		$primary_registrant = $transaction->primary_registration();
@@ -107,47 +107,47 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$total_discounts_to_cart_total = $transaction->paid();
109 109
 		//only itemize the order if we're paying for the rest of the order's amount
110
-		if( $payment->amount() == $transaction->total() ) {
111
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
110
+		if ($payment->amount() == $transaction->total()) {
111
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
112 112
 			//this payment is for the remaining transaction amount,
113 113
 			//keep track of exactly how much the itemized order amount equals
114 114
 			$itemized_sum = 0;
115 115
 			$shipping_previously_added = 0;
116 116
 			//so let's show all the line items
117
-			foreach($total_line_item->get_items() as $line_item){
118
-				if ( $line_item instanceof EE_Line_Item ) {
117
+			foreach ($total_line_item->get_items() as $line_item) {
118
+				if ($line_item instanceof EE_Line_Item) {
119 119
 					//it's some kind of discount
120
-					if( $line_item->total() < 0 ) {
121
-						$total_discounts_to_cart_total += abs( $line_item->total() );
120
+					if ($line_item->total() < 0) {
121
+						$total_discounts_to_cart_total += abs($line_item->total());
122 122
 						$itemized_sum += $line_item->total();
123 123
 						continue;
124 124
 					}
125 125
 					//dont include shipping again.
126
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
126
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
127 127
 						$shipping_previously_added = $line_item->total();
128 128
 						continue;
129 129
 					}
130
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
130
+					$redirect_args['item_name_'.$item_num] = substr(
131 131
 						sprintf(
132
-							_x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ),
132
+							_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'),
133 133
 							$line_item->name(),
134 134
 							$line_item->ticket_event_name()
135 135
 						),
136 136
 						0,
137 137
 						127
138 138
 					);
139
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
140
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
139
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
140
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
141 141
 					//if we're not letting PayPal calculate shipping, tell them its 0
142
-					if ( ! $this->_paypal_shipping ) {
143
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
144
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
142
+					if ( ! $this->_paypal_shipping) {
143
+						$redirect_args['shipping_'.$item_num] = '0';
144
+						$redirect_args['shipping2_'.$item_num] = '0';
145 145
 					}
146 146
 					$item_num++;
147 147
 					$itemized_sum += $line_item->total();
148 148
 				}
149 149
 			}
150
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
150
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
151 151
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
152 152
 			//and the itemized sum is LESS than the transaction total
153 153
 			//add another line item
@@ -157,47 +157,47 @@  discard block
 block discarded – undo
157 157
 					$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
158 158
 					2 
159 159
 				);
160
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
160
+			if ($itemized_sum_diff_from_txn_total < 0) {
161 161
 				//itemized sum is too big
162
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
163
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
164
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
165
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
166
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
167
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
162
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
163
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
164
+				$redirect_args['item_name_'.$item_num] = substr(
165
+						__('Other charges', 'event_espresso'), 0, 127 );
166
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
167
+				$redirect_args['quantity_'.$item_num] = 1;
168 168
 				$item_num++;
169 169
 			}
170
-			if( $total_discounts_to_cart_total > 0 ) {
171
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
170
+			if ($total_discounts_to_cart_total > 0) {
171
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
172 172
 			}
173 173
 			//add our taxes to the order if we're NOT using PayPal's
174
-			if( ! $this->_paypal_taxes ){
174
+			if ( ! $this->_paypal_taxes) {
175 175
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
176 176
 			}
177 177
 		} else {
178
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
178
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
179 179
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
180
-			$redirect_args['item_name_' . $item_num] = substr(
181
-				sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ),
180
+			$redirect_args['item_name_'.$item_num] = substr(
181
+				sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()),
182 182
 				0, 127
183 183
 			);
184
-			$redirect_args['amount_' . $item_num] = $payment->amount();
185
-			$redirect_args['shipping_' . $item_num ] = '0';
186
-			$redirect_args['shipping2_' . $item_num ] = '0';
184
+			$redirect_args['amount_'.$item_num] = $payment->amount();
185
+			$redirect_args['shipping_'.$item_num] = '0';
186
+			$redirect_args['shipping2_'.$item_num] = '0';
187 187
 			$redirect_args['tax_cart'] = '0';
188 188
 			$item_num++;
189 189
 		}
190 190
 
191
-		if($this->_debug_mode){
192
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
193
-			$redirect_args['amount_' . $item_num] = 0;
191
+		if ($this->_debug_mode) {
192
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
193
+			$redirect_args['amount_'.$item_num] = 0;
194 194
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
195
-			$redirect_args['os0_' . $item_num] = $notify_url;
195
+			$redirect_args['os0_'.$item_num] = $notify_url;
196 196
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
197
-			$redirect_args['os1_' . $item_num] = $return_url;
197
+			$redirect_args['os1_'.$item_num] = $return_url;
198 198
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
199
-			$redirect_args['shipping_' . $item_num ] = '0';
200
-			$redirect_args['shipping2_' . $item_num ] = '0';
199
+			$redirect_args['shipping_'.$item_num] = '0';
200
+			$redirect_args['shipping2_'.$item_num] = '0';
201 201
 		}
202 202
 
203 203
 		$redirect_args['business'] = $this->_paypal_id;
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 		$redirect_args['cmd'] = '_cart';
208 208
 		$redirect_args['upload'] = 1;
209 209
 		$redirect_args['currency_code'] = $payment->currency_code();
210
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
211
-		if($this->_image_url){
210
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
211
+		if ($this->_image_url) {
212 212
 			$redirect_args['image_url'] = $this->_image_url;
213 213
 		}
214 214
 		$redirect_args['no_shipping'] = $this->_shipping_details;
215
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
215
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
216 216
 
217
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
217
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
218 218
 
219 219
 		$payment->set_redirect_url($this->_gateway_url);
220 220
 		$payment->set_redirect_args($redirect_args);
@@ -235,55 +235,55 @@  discard block
 block discarded – undo
235 235
 	 * @return \EEI_Payment updated
236 236
 	 * @throws \EE_Error
237 237
 	 */
238
-	public function handle_payment_update( $update_info, $transaction ){
238
+	public function handle_payment_update($update_info, $transaction) {
239 239
 		//verify there's payment data that's been sent
240
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
240
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
241 241
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
242 242
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
243
-			if ( isset( $update_info[ 'tx' ] ) ) {
243
+			if (isset($update_info['tx'])) {
244 244
 				return $transaction->last_payment();
245 245
 			} else {
246 246
 				return null;
247 247
 			}
248 248
 		}
249
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
250
-		if ( ! $payment instanceof EEI_Payment ) {
249
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
250
+		if ( ! $payment instanceof EEI_Payment) {
251 251
 			$payment = $transaction->last_payment();
252 252
 		}
253 253
 		// ok, then validate the IPN. Even if we've already processed this payment,
254 254
 		// let PayPal know we don't want to hear from them anymore!
255
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
255
+		if ( ! $this->validate_ipn($update_info, $payment)) {
256 256
 			return $payment;
257 257
 		}
258 258
 		//ok, well let's process this payment then!
259
-		switch ( $update_info[ 'payment_status' ] ) {
259
+		switch ($update_info['payment_status']) {
260 260
 
261 261
 			case 'Completed' :
262 262
 				$status = $this->_pay_model->approved_status();
263
-				$gateway_response = __( 'The payment is approved.', 'event_espresso' );
263
+				$gateway_response = __('The payment is approved.', 'event_espresso');
264 264
 				break;
265 265
 
266 266
 			case 'Pending' :
267 267
 				$status = $this->_pay_model->pending_status();
268
-				$gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
268
+				$gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
269 269
 				break;
270 270
 
271 271
 			case 'Denied' :
272 272
 				$status = $this->_pay_model->declined_status();
273
-				$gateway_response = __( 'The payment has been declined.', 'event_espresso' );
273
+				$gateway_response = __('The payment has been declined.', 'event_espresso');
274 274
 				break;
275 275
 
276 276
 			case 'Expired' :
277 277
 			case 'Failed' :
278 278
 				$status = $this->_pay_model->failed_status();
279
-				$gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' );
279
+				$gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso');
280 280
 				break;
281 281
 
282 282
 			case 'Refunded' :
283 283
 			case 'Partially_Refunded' :
284 284
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
285 285
 				$status = $this->_pay_model->approved_status();
286
-				$gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
286
+				$gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
287 287
 				break;
288 288
 
289 289
 			case 'Voided' :
@@ -291,25 +291,25 @@  discard block
 block discarded – undo
291 291
 			case 'Canceled_Reversal' :
292 292
 			default :
293 293
 				$status = $this->_pay_model->cancelled_status();
294
-				$gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
294
+				$gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
295 295
 				break;
296 296
 
297 297
 		}
298 298
 
299 299
 		//check if we've already processed this payment
300
-		if ( $payment instanceof EEI_Payment ) {
300
+		if ($payment instanceof EEI_Payment) {
301 301
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
302
-			if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) {
302
+			if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) {
303 303
 				// DUPLICATED IPN! dont bother updating transaction foo!;
304
-				$message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() );
304
+				$message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID());
305 305
 			} else {
306 306
 				// new payment yippee !!!
307
-				$payment->set_status( $status );
308
-				$payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) );
309
-				$payment->set_gateway_response( $gateway_response );
310
-				$payment->set_details( $update_info );
311
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
312
-				$message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) );
307
+				$payment->set_status($status);
308
+				$payment->set_amount(floatval($update_info['mc_gross']));
309
+				$payment->set_gateway_response($gateway_response);
310
+				$payment->set_details($update_info);
311
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
312
+				$message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'));
313 313
 			}
314 314
 			$this->log(
315 315
 				array(
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 				$payment
322 322
 			);
323 323
 		}
324
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
324
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
325 325
 		// kill request here if this is a refund
326
-		if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded'   ) {
327
-			if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) {
328
-				status_header( 200 );
326
+		if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') {
327
+			if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) {
328
+				status_header(200);
329 329
 				exit();
330 330
 			}
331 331
 		}
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 	 * @param EE_Payment|EEI_Payment $payment
342 342
 	 * @return boolean
343 343
 	 */
344
-	public function validate_ipn( $update_info, $payment ) {
344
+	public function validate_ipn($update_info, $payment) {
345 345
 		//allow us to skip validating IPNs with PayPal (useful for testing)
346
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
346
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
347 347
 			return true;
348 348
 		}
349 349
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -351,22 +351,22 @@  discard block
 block discarded – undo
351 351
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
352 352
 		// Instead, read raw POST data from the input stream.
353 353
 		// @see https://gist.github.com/xcommerce-gists/3440401
354
-		$raw_post_data = file_get_contents( 'php://input' );
355
-		$raw_post_array = explode( '&', $raw_post_data );
354
+		$raw_post_data = file_get_contents('php://input');
355
+		$raw_post_array = explode('&', $raw_post_data);
356 356
 		$update_info = array();
357
-		foreach ( $raw_post_array as $keyval ) {
358
-			$keyval = explode( '=', $keyval );
359
-			if ( count( $keyval ) == 2 )
360
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
357
+		foreach ($raw_post_array as $keyval) {
358
+			$keyval = explode('=', $keyval);
359
+			if (count($keyval) == 2)
360
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
361 361
 		}
362 362
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
363 363
 		$req = 'cmd=_notify-validate';
364
-		$get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false;
365
-		foreach ( $update_info as $key => $value ) {
366
-			if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) {
367
-				$value = urlencode( stripslashes( $value ) );
364
+		$get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false;
365
+		foreach ($update_info as $key => $value) {
366
+			if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) {
367
+				$value = urlencode(stripslashes($value));
368 368
 			} else {
369
-				$value = urlencode( $value );
369
+				$value = urlencode($value);
370 370
 			}
371 371
 			$req .= "&$key=$value";
372 372
 		}
@@ -376,34 +376,34 @@  discard block
 block discarded – undo
376 376
 			array(
377 377
 				'body' 				=> $req,
378 378
 				'sslverify' 		=> false,
379
-				'timeout' 		=> 60 ,
379
+				'timeout' 		=> 60,
380 380
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
381 381
 				// plz see: https://github.com/websharks/s2member/issues/610
382
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
382
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
383 383
 				'httpversion' => '1.1'
384 384
 			)
385 385
 		);
386 386
 		// then check the response
387
-		if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) {
387
+		if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) {
388 388
 			return true;
389 389
 		} else {
390 390
 			// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
391 391
 			// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
392
-			if( is_wp_error(  $response ) ) {
392
+			if (is_wp_error($response)) {
393 393
 				$error_msg = sprintf( 
394
-					__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ),
394
+					__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
395 395
 					$response->get_error_code(),
396 396
 					$response->get_error_message(),
397
-					print_r( $response->get_error_data, true )
397
+					print_r($response->get_error_data, true)
398 398
 				);
399
-			} elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) {
400
-				$error_msg = $response[ 'body' ];
399
+			} elseif (is_array($response) && isset($response['body'])) {
400
+				$error_msg = $response['body'];
401 401
 			} else {
402
-				$error_msg = print_r( $response, true );
402
+				$error_msg = print_r($response, true);
403 403
 			}
404
-			$payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) );
405
-			$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
406
-			$payment->set_status( EEM_Payment::status_id_failed );
404
+			$payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg));
405
+			$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
406
+			$payment->set_status(EEM_Payment::status_id_failed);
407 407
 			// log the results
408 408
 			$this->log(
409 409
 				array(
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 	 */
426 426
 	protected function _process_response_url() {
427 427
 		EE_Registry::instance()->load_helper('URL');
428
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
428
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
429 429
 			$url = is_ssl() ? 'https://' : 'http://';
430
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
430
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
431 431
 			$url .= EEH_URL::filter_input_server_url();
432 432
 		} else {
433 433
 			$url = 'unknown';
@@ -443,30 +443,30 @@  discard block
 block discarded – undo
443 443
 	 * like the taxes or shipping
444 444
 	 * @param EEI_Payment $payment
445 445
 	 */
446
-	public function update_txn_based_on_payment( $payment ) {
446
+	public function update_txn_based_on_payment($payment) {
447 447
 		$update_info = $payment->details();
448 448
 		$transaction = $payment->transaction();
449
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
450
-		if( ! $transaction ){
451
-			$this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment );
449
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
450
+		if ( ! $transaction) {
451
+			$this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment);
452 452
 			return;
453 453
 		}
454
-		if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) {
454
+		if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) {
455 455
 			$this->log(
456 456
 				array(
457 457
 					'url' 				=> $this->_process_response_url(),
458
-					'message' 	=> __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ),
458
+					'message' 	=> __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'),
459 459
 					'payment' 	=> $payment->model_field_array()
460 460
 				),
461 461
 				$payment
462 462
 			);
463 463
 			return;
464 464
 		}
465
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
465
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
466 466
 			$this->log(
467 467
 				array(
468 468
 					'url' 				=> $this->_process_response_url(),
469
-					'message' 	=> __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ),
469
+					'message' 	=> __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'),
470 470
 					'payment' 	=> $payment->model_field_array()
471 471
 				),
472 472
 				$payment
@@ -476,43 +476,43 @@  discard block
 block discarded – undo
476 476
 		$grand_total_needs_resaving = false;
477 477
 
478 478
 		//might paypal have changed the taxes?
479
-		if( $this->_paypal_taxes && $payment_was_itemized ){
479
+		if ($this->_paypal_taxes && $payment_was_itemized) {
480 480
                     //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
481
-                    $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
481
+                    $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping');
482 482
                     $this->_line_item->set_total_tax_to(
483 483
                             $transaction->total_line_item(),
484
-                            floatval( $update_info['tax'] ),
485
-                            __( 'Taxes', 'event_espresso' ),
486
-                            __( 'Calculated by Paypal', 'event_espresso' ),
484
+                            floatval($update_info['tax']),
485
+                            __('Taxes', 'event_espresso'),
486
+                            __('Calculated by Paypal', 'event_espresso'),
487 487
                             'paypal_tax'
488 488
                     );
489 489
                     $grand_total_needs_resaving = TRUE;
490 490
 		}
491 491
 
492
-		$shipping_amount = floatval( $update_info[ 'mc_shipping' ] );
492
+		$shipping_amount = floatval($update_info['mc_shipping']);
493 493
 		//might paypal have added shipping?
494
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
494
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
495 495
 			$this->_line_item->add_unrelated_item(
496 496
 				$transaction->total_line_item(),
497
-				sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
497
+				sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
498 498
 				$shipping_amount,
499 499
 				__('Shipping charges calculated by Paypal', 'event_espresso'),
500 500
 				1,
501 501
 				false,
502
-				'paypal_shipping_' . $transaction->ID()
502
+				'paypal_shipping_'.$transaction->ID()
503 503
 			);
504 504
 			$grand_total_needs_resaving = true;
505 505
 		}
506 506
 
507
-		if( $grand_total_needs_resaving ){
508
-			$transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() );
509
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
510
-			$registration_processor->update_registration_final_prices( $transaction );
507
+		if ($grand_total_needs_resaving) {
508
+			$transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID());
509
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
510
+			$registration_processor->update_registration_final_prices($transaction);
511 511
 		}
512 512
 		$this->log(
513 513
 			array(
514 514
 				'url' 													=> $this->_process_response_url(),
515
-				'message' 										=> __( 'Updated transaction related to payment', 'event_espresso' ),
515
+				'message' 										=> __('Updated transaction related to payment', 'event_espresso'),
516 516
 				'transaction (updated)' 					=> $transaction->model_field_array(),
517 517
 				'payment (updated)' 						=> $payment->model_field_array(),
518 518
 				'use_paypal_shipping' 					=> $this->_paypal_shipping,
Please login to merge, or discard this patch.
Registration_Form_Question_Groups_Admin_List_Table.class.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 class Registration_Form_Question_Groups_Admin_List_Table extends EE_Admin_List_Table {
32 32
 
33 33
 
34
-	public function __construct( $admin_page ) {
34
+	public function __construct($admin_page) {
35 35
 		parent::__construct($admin_page);
36 36
 	}
37 37
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
 
41 41
 	protected function _setup_data() {
42
-		$this->_data = $this->_view != 'trash' ? $this->_admin_page->get_question_groups( $this->_per_page,$this->_current_page, FALSE ) : $this->_admin_page->get_trashed_question_groups( $this->_per_page,$this->_current_page, FALSE );
43
-		$this->_all_data_count = $this->_view != 'trash' ? $this->_admin_page->get_question_groups( $this->_per_page,$this->_current_page, TRUE ) : $this->_admin_page->get_trashed_question_groups( $this->_per_page,$this->_current_page, TRUE );
42
+		$this->_data = $this->_view != 'trash' ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, FALSE) : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, FALSE);
43
+		$this->_all_data_count = $this->_view != 'trash' ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, TRUE) : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, TRUE);
44 44
 	}
45 45
 
46 46
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 
50 50
 	protected function _set_properties() {
51 51
 		$this->_wp_list_args = array(
52
-			'singular' => __('question group', 'event_espresso' ),
53
-			'plural' => __('question groups', 'event_espresso' ),
52
+			'singular' => __('question group', 'event_espresso'),
53
+			'plural' => __('question groups', 'event_espresso'),
54 54
 			'ajax' => TRUE, //for now,
55 55
 			'screen' => $this->_admin_page->get_current_screen()->id
56 56
 			);
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 			);
66 66
 
67 67
 		$this->_sortable_columns = array(
68
-			'id' => array( 'QSG_ID' => FALSE ),
69
-			'name' => array( 'QSG_name' => FALSE )
68
+			'id' => array('QSG_ID' => FALSE),
69
+			'name' => array('QSG_name' => FALSE)
70 70
 			);
71 71
 
72 72
 		$this->_hidden_columns = array(
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 
94 94
 	protected function _add_view_counts() {
95
-		$this->_views['all']['count'] = $this->_admin_page->get_question_groups( $this->_per_page,$this->_current_page, TRUE );
96
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_group' ) ) {
97
-			$this->_views['trash']['count'] = $this->_admin_page->get_trashed_question_groups( $this->_per_page,$this->_current_page, TRUE );
95
+		$this->_views['all']['count'] = $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, TRUE);
96
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_group')) {
97
+			$this->_views['trash']['count'] = $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, TRUE);
98 98
 		}
99 99
 	}
100 100
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		$system_group = $item->get('QSG_system');
108 108
 		$has_questions_with_answers = $item->has_questions_with_answers();
109 109
 		$lock_icon = $system_group === 0 && $this->_view == 'trash' && $has_questions_with_answers ? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock';
110
-		return $system_group > 0 || ( $system_group === 0 && $this->_view == 'trash' && $has_questions_with_answers ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups', $item->ID() ) ? '<span class="' . $lock_icon . '"></span>'  . sprintf( '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', $item->ID() )  : sprintf( '<input type="checkbox" id="QSG_ID[%1$d]" name="checkbox[%1$d]" value="%1$d" />', $item->ID() );
110
+		return $system_group > 0 || ($system_group === 0 && $this->_view == 'trash' && $has_questions_with_answers) || ! EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups', $item->ID()) ? '<span class="'.$lock_icon.'"></span>'.sprintf('<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', $item->ID()) : sprintf('<input type="checkbox" id="QSG_ID[%1$d]" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
111 111
 	}
112 112
 
113 113
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	public function column_id(EE_Question_Group $item) {
119 119
 		$content = $item->ID();
120
-		$content .= '  <span class="show-on-mobile-view-only">' .$item->name() . '</span>';
120
+		$content .= '  <span class="show-on-mobile-view-only">'.$item->name().'</span>';
121 121
 		return $content;
122 122
 	}
123 123
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		$actions = array();
128 128
 
129 129
 		//return $item->name();
130
-		if ( !defined('REG_ADMIN_URL') )
130
+		if ( ! defined('REG_ADMIN_URL'))
131 131
 			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
132 132
 
133 133
 		$edit_query_args = array(
@@ -152,32 +152,32 @@  discard block
 block discarded – undo
152 152
 
153 153
 
154 154
 
155
-		$edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EE_FORMS_ADMIN_URL );
156
-		$trash_link = EE_Admin_Page::add_query_args_and_nonce( $trash_query_args, EE_FORMS_ADMIN_URL );
157
-		$restore_link = EE_Admin_Page::add_query_args_and_nonce( $restore_query_args, EE_FORMS_ADMIN_URL );
158
-		$delete_link = EE_Admin_Page::add_query_args_and_nonce( $delete_query_args, EE_FORMS_ADMIN_URL );
155
+		$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL);
156
+		$trash_link = EE_Admin_Page::add_query_args_and_nonce($trash_query_args, EE_FORMS_ADMIN_URL);
157
+		$restore_link = EE_Admin_Page::add_query_args_and_nonce($restore_query_args, EE_FORMS_ADMIN_URL);
158
+		$delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_FORMS_ADMIN_URL);
159 159
 
160
-		if (  EE_Registry::instance()->CAP->current_user_can( 'ee_edit_question_group', 'espresso_registration_form_edit_question_group', $item->ID() ) ) {
160
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_question_group', 'espresso_registration_form_edit_question_group', $item->ID())) {
161 161
 			$actions = array(
162
-				'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Question Group', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'
162
+				'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Question Group', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'
163 163
 			);
164 164
 		}
165
-		if ( $item->get('QSG_system') < 1 && $this->_view != 'trash' &&  EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_group', 'espresso_registration_form_trash_question_group', $item->ID() ) ) {
166
-			$actions['delete'] = '<a href="' . $trash_link . '" title="' . esc_attr__('Delete Question Group', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
165
+		if ($item->get('QSG_system') < 1 && $this->_view != 'trash' && EE_Registry::instance()->CAP->current_user_can('ee_delete_question_group', 'espresso_registration_form_trash_question_group', $item->ID())) {
166
+			$actions['delete'] = '<a href="'.$trash_link.'" title="'.esc_attr__('Delete Question Group', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>';
167 167
 		}
168 168
 
169
-		if ( $this->_view == 'trash' ) {
169
+		if ($this->_view == 'trash') {
170 170
 
171
-			if (  EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_group', 'espresso_registration_form_restore_question_group', $item->ID() ) ) {
172
-				$actions['restore'] = '<a href="' . $restore_link . '" title="' . esc_attr__('Restore Question Group', 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
171
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_group', 'espresso_registration_form_restore_question_group', $item->ID())) {
172
+				$actions['restore'] = '<a href="'.$restore_link.'" title="'.esc_attr__('Restore Question Group', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
173 173
 			}
174 174
 
175
-			if ( !$item->has_questions_with_answers() &&  EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_group', 'espresso_registration_form_delete_question_group', $item->ID() ) ) {
176
-				$actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__('Delete Question Group Permanently', 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>';
175
+			if ( ! $item->has_questions_with_answers() && EE_Registry::instance()->CAP->current_user_can('ee_delete_question_group', 'espresso_registration_form_delete_question_group', $item->ID())) {
176
+				$actions['delete'] = '<a href="'.$delete_link.'" title="'.esc_attr__('Delete Question Group Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>';
177 177
 			}
178 178
 		}
179 179
 
180
-		$content =  EE_Registry::instance()->CAP->current_user_can( 'ee_edit_question_group', 'espresso_registration_form_edit_question_group', $item->ID() ) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' : $item->name();
180
+		$content = EE_Registry::instance()->CAP->current_user_can('ee_edit_question_group', 'espresso_registration_form_edit_question_group', $item->ID()) ? '<strong><a class="row-title" href="'.$edit_link.'">'.$item->name().'</a></strong>' : $item->name();
181 181
 		$content .= $this->row_actions($actions);
182 182
 		return $content;
183 183
 	}
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 
199 199
 
200 200
 	public function column_show_group_name(EE_Question_Group $item) {
201
-		return $this->_yes_no[ $item->show_group_name() ];
201
+		return $this->_yes_no[$item->show_group_name()];
202 202
 	}
203 203
 
204 204
 
205 205
 
206 206
 	public function column_show_group_desc(EE_Question_Group $item) {
207
-		return $this->_yes_no[ $item->show_group_desc() ];
207
+		return $this->_yes_no[$item->show_group_desc()];
208 208
 	}
209 209
 
210 210
 
Please login to merge, or discard this patch.
core/db_classes/EE_Question.class.php 3 patches
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	/**
185 185
 	 * returns the text for displaying the question to users
186 186
 	 * @access public
187
-	 * @return string
187
+	 * @return boolean
188 188
 	 */
189 189
 	public function display_text() {
190 190
 		return $this->get( 'QST_display_text' );
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	/**
196 196
 	 * returns the text for the administrative label
197 197
 	 * @access public
198
-	 * @return string
198
+	 * @return boolean
199 199
 	 */
200 200
 	public function admin_label() {
201 201
 		return $this->get( 'QST_admin_label' );
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	/**
207 207
 	 * returns the attendee column name for this question
208 208
 	 * @access public
209
-	 * @return string
209
+	 * @return boolean
210 210
 	 */
211 211
 	public function system_ID() {
212 212
 		return $this->get( 'QST_system' );
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * returns the text which should be displayed when a user
230 230
 	 * doesn't answer this question in a form
231 231
 	 * @access public
232
-	 * @return string
232
+	 * @return boolean
233 233
 	 */
234 234
 	public function required_text() {
235 235
 		return $this->get( 'QST_required_text' );
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	/**
241 241
 	 * returns the type of this question
242 242
 	 * @access public
243
-	 * @return string
243
+	 * @return boolean
244 244
 	 */
245 245
 	public function type() {
246 246
 		return $this->get( 'QST_type' );
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * returns an integer showing where this question should
253 253
 	 * be placed in a sequence of questions
254 254
 	 * @access public
255
-	 * @return int
255
+	 * @return boolean
256 256
 	 */
257 257
 	public function order() {
258 258
 		return $this->get( 'QST_order' );
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	/**
276 276
 	 * returns the id the wordpress user who created this question
277 277
 	 * @access public
278
-	 * @return int
278
+	 * @return boolean
279 279
 	 */
280 280
 	public function wp_user() {
281 281
 		return $this->get( 'QST_wp_user' );
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * Adds an option for this question. Note: if the option were previously associated with a different
370 370
 	 * Question, that relationship will be overwritten.
371 371
 	 * @param EE_Question_Option $option
372
-	 * @return boolean success
372
+	 * @return EE_Base_Class success
373 373
 	 */
374 374
 	public function add_option( EE_Question_Option $option ) {
375 375
 		return $this->_add_relation_to( $option, 'Question_Option' );
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	/**
393 393
 	 * Marks the option as deleted.
394 394
 	 * @param EE_Question_Option $option
395
-	 * @return boolean success
395
+	 * @return EE_Base_Class success
396 396
 	 */
397 397
 	public function remove_option( EE_Question_Option $option ) {
398 398
 		return $this->_remove_relation_to( $option, 'Question_Option' );
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	
462 462
 	/**
463 463
 	 * Returns the question's maximum allowed response size
464
-	 * @return int|float
464
+	 * @return boolean
465 465
 	 */
466 466
 	public function max() {
467 467
 		return $this->get( 'QST_max' );
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	 *                             		    date_format and the second value is the time format
38 38
 	 * @return EE_Question
39 39
 	 */
40
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
41
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
42
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
40
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
41
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
42
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
43 43
 	}
44 44
 
45 45
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 *                          		the website will be used.
51 51
 	 * @return EE_Question
52 52
 	 */
53
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
54
-		return new self( $props_n_values, TRUE, $timezone );
53
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
54
+		return new self($props_n_values, TRUE, $timezone);
55 55
 	}
56 56
 
57 57
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @access        public
63 63
 	 * @param string $QST_display_text
64 64
 	 */
65
-	public function set_display_text( $QST_display_text = '' ) {
66
-		$this->set( 'QST_display_text', $QST_display_text );
65
+	public function set_display_text($QST_display_text = '') {
66
+		$this->set('QST_display_text', $QST_display_text);
67 67
 	}
68 68
 
69 69
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @access        public
75 75
 	 * @param        string $QST_admin_label
76 76
 	 */
77
-	public function set_admin_label( $QST_admin_label = '' ) {
78
-		$this->set( 'QST_admin_label', $QST_admin_label );
77
+	public function set_admin_label($QST_admin_label = '') {
78
+		$this->set('QST_admin_label', $QST_admin_label);
79 79
 	}
80 80
 
81 81
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @access        public
87 87
 	 * @param        mixed $QST_system
88 88
 	 */
89
-	public function set_system_ID( $QST_system = '' ) {
90
-		$this->set( 'QST_system', $QST_system );
89
+	public function set_system_ID($QST_system = '') {
90
+		$this->set('QST_system', $QST_system);
91 91
 	}
92 92
 
93 93
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @access        public
99 99
 	 * @param        string $QST_type
100 100
 	 */
101
-	public function set_question_type( $QST_type = '' ) {
102
-		$this->set( 'QST_type', $QST_type );
101
+	public function set_question_type($QST_type = '') {
102
+		$this->set('QST_type', $QST_type);
103 103
 	}
104 104
 
105 105
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @access        public
111 111
 	 * @param        bool $QST_required
112 112
 	 */
113
-	public function set_required( $QST_required = FALSE ) {
114
-		$this->set( 'QST_required', $QST_required );
113
+	public function set_required($QST_required = FALSE) {
114
+		$this->set('QST_required', $QST_required);
115 115
 	}
116 116
 
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @access        public
123 123
 	 * @param        string $QST_required_text
124 124
 	 */
125
-	public function set_required_text( $QST_required_text = '' ) {
126
-		$this->set( 'QST_required_text', $QST_required_text );
125
+	public function set_required_text($QST_required_text = '') {
126
+		$this->set('QST_required_text', $QST_required_text);
127 127
 	}
128 128
 
129 129
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @access        public
135 135
 	 * @param        int $QST_order
136 136
 	 */
137
-	public function set_order( $QST_order = 0 ) {
138
-		$this->set( 'QST_order', $QST_order );
137
+	public function set_order($QST_order = 0) {
138
+		$this->set('QST_order', $QST_order);
139 139
 	}
140 140
 
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @access        public
147 147
 	 * @param        bool $QST_admin_only
148 148
 	 */
149
-	public function set_admin_only( $QST_admin_only = FALSE ) {
150
-		$this->set( 'QST_admin_only', $QST_admin_only );
149
+	public function set_admin_only($QST_admin_only = FALSE) {
150
+		$this->set('QST_admin_only', $QST_admin_only);
151 151
 	}
152 152
 
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @access        public
159 159
 	 * @param        int $QST_wp_user
160 160
 	 */
161
-	public function set_wp_user( $QST_wp_user = 1 ) {
162
-		$this->set( 'QST_wp_user', $QST_wp_user );
161
+	public function set_wp_user($QST_wp_user = 1) {
162
+		$this->set('QST_wp_user', $QST_wp_user);
163 163
 	}
164 164
 
165 165
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @access        public
176 176
 	 * @param 	bool $QST_deleted
177 177
 	 */
178
-	public function set_deleted( $QST_deleted = FALSE ) {
179
-		$this->set( 'QST_deleted', $QST_deleted );
178
+	public function set_deleted($QST_deleted = FALSE) {
179
+		$this->set('QST_deleted', $QST_deleted);
180 180
 	}
181 181
 
182 182
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	public function display_text() {
190
-		return $this->get( 'QST_display_text' );
190
+		return $this->get('QST_display_text');
191 191
 	}
192 192
 
193 193
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string
199 199
 	 */
200 200
 	public function admin_label() {
201
-		return $this->get( 'QST_admin_label' );
201
+		return $this->get('QST_admin_label');
202 202
 	}
203 203
 
204 204
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function system_ID() {
212
-		return $this->get( 'QST_system' );
212
+		return $this->get('QST_system');
213 213
 	}
214 214
 
215 215
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return boolean
221 221
 	 */
222 222
 	public function required() {
223
-		return $this->get( 'QST_required' );
223
+		return $this->get('QST_required');
224 224
 	}
225 225
 
226 226
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return string
233 233
 	 */
234 234
 	public function required_text() {
235
-		return $this->get( 'QST_required_text' );
235
+		return $this->get('QST_required_text');
236 236
 	}
237 237
 
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return string
244 244
 	 */
245 245
 	public function type() {
246
-		return $this->get( 'QST_type' );
246
+		return $this->get('QST_type');
247 247
 	}
248 248
 
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @return int
256 256
 	 */
257 257
 	public function order() {
258
-		return $this->get( 'QST_order' );
258
+		return $this->get('QST_order');
259 259
 	}
260 260
 
261 261
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return boolean
268 268
 	 */
269 269
 	public function admin_only() {
270
-		return $this->get( 'QST_admin_only' );
270
+		return $this->get('QST_admin_only');
271 271
 	}
272 272
 
273 273
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return int
279 279
 	 */
280 280
 	public function wp_user() {
281
-		return $this->get( 'QST_wp_user' );
281
+		return $this->get('QST_wp_user');
282 282
 	}
283 283
 
284 284
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return boolean
290 290
 	 */
291 291
 	public function deleted() {
292
-		return $this->get( 'QST_deleted' );
292
+		return $this->get('QST_deleted');
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return EE_Answer[]
300 300
 	 */
301 301
 	public function answers() {
302
-		return $this->get_many_related( 'Answer' );
302
+		return $this->get_many_related('Answer');
303 303
 	}
304 304
 
305 305
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return boolean true = has answers, false = no answers.
310 310
 	 */
311 311
 	public function has_answers() {
312
-		return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE;
312
+		return $this->count_related('Answer') > 0 ? TRUE : FALSE;
313 313
 	}
314 314
 
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return EE_Question_Group[]
320 320
 	 */
321 321
 	public function question_groups() {
322
-		return $this->get_many_related( 'Question_Group' );
322
+		return $this->get_many_related('Question_Group');
323 323
 	}
324 324
 
325 325
 
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
 	 *                                                       whether it was trashed or not.
334 334
 	 * @return EE_Question_Option[]
335 335
 	 */
336
-	public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) {
337
-		if ( ! $this->ID() ) {
336
+	public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) {
337
+		if ( ! $this->ID()) {
338 338
 			return array();
339 339
 		}
340 340
 		$query_params = array();
341
-		if ( $selected_value_to_always_include ) {
342
-			if ( is_array( $selected_value_to_always_include ) ) {
343
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include );
341
+		if ($selected_value_to_always_include) {
342
+			if (is_array($selected_value_to_always_include)) {
343
+				$query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
344 344
 			} else {
345
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include;
345
+				$query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
346 346
 			}
347 347
 		}
348
-		if ( $notDeletedOptionsOnly ) {
349
-			$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE;
348
+		if ($notDeletedOptionsOnly) {
349
+			$query_params[0]['OR*options-query']['QSO_deleted'] = FALSE;
350 350
 		}
351 351
 		//order by QSO_order
352
-		$query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' );
353
-		return $this->get_many_related( 'Question_Option', $query_params );
352
+		$query_params['order_by'] = array('QSO_order' => 'ASC');
353
+		return $this->get_many_related('Question_Option', $query_params);
354 354
 	}
355 355
 
356 356
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return \EE_Question_Option[]
361 361
 	 */
362 362
 	public function temp_options() {
363
-		return $this->_model_relations[ 'Question_Option' ];
363
+		return $this->_model_relations['Question_Option'];
364 364
 	}
365 365
 
366 366
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param EE_Question_Option $option
372 372
 	 * @return boolean success
373 373
 	 */
374
-	public function add_option( EE_Question_Option $option ) {
375
-		return $this->_add_relation_to( $option, 'Question_Option' );
374
+	public function add_option(EE_Question_Option $option) {
375
+		return $this->_add_relation_to($option, 'Question_Option');
376 376
 	}
377 377
 
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param EE_Question_Option $option
383 383
 	 * @return boolean success
384 384
 	 */
385
-	public function add_temp_option( EE_Question_Option $option ) {
386
-		$this->_model_relations[ 'Question_Option' ][ ] = $option;
385
+	public function add_temp_option(EE_Question_Option $option) {
386
+		$this->_model_relations['Question_Option'][] = $option;
387 387
 		return TRUE;
388 388
 	}
389 389
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param EE_Question_Option $option
395 395
 	 * @return boolean success
396 396
 	 */
397
-	public function remove_option( EE_Question_Option $option ) {
398
-		return $this->_remove_relation_to( $option, 'Question_Option' );
397
+	public function remove_option(EE_Question_Option $option) {
398
+		return $this->_remove_relation_to($option, 'Question_Option');
399 399
 	}
400 400
 
401 401
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @return bool
405 405
 	 */
406 406
 	public function is_system_question() {
407
-		$system_ID = $this->get( 'QST_system' );
408
-		return ! empty( $system_ID ) ? TRUE : FALSE;
407
+		$system_ID = $this->get('QST_system');
408
+		return ! empty($system_ID) ? TRUE : FALSE;
409 409
 	}
410 410
 
411 411
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	public function set_order_to_latest() {
420 420
 		$latest_order = $this->get_model()->get_latest_question_order();
421
-		$latest_order ++;
422
-		$this->set( 'QST_order', $latest_order );
421
+		$latest_order++;
422
+		$this->set('QST_order', $latest_order);
423 423
 	}
424 424
 
425 425
 
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 	 * Duplicates this question and its question options
439 439
 	 * @return \EE_Question
440 440
 	 */
441
-	public function duplicate( $options = array() ) {
441
+	public function duplicate($options = array()) {
442 442
 		$new_question = clone $this;
443
-		$new_question->set( 'QST_ID', null );
444
-		$new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) );
445
-		$new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) );
446
-		$new_question->set_system_ID( null );
447
-		$new_question->set_wp_user( get_current_user_id() );
443
+		$new_question->set('QST_ID', null);
444
+		$new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
445
+		$new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
446
+		$new_question->set_system_ID(null);
447
+		$new_question->set_wp_user(get_current_user_id());
448 448
                 //if we're duplicating a trashed question, assume we don't want the new one to be trashed
449
-                $new_question->set_deleted( false );
449
+                $new_question->set_deleted(false);
450 450
 		$success = $new_question->save();
451
-		if( $success ) {
451
+		if ($success) {
452 452
 			//we don't totally want to duplicate the question options, because we want them to be for the NEW question
453
-			foreach( $this->options() as $question_option ) {
454
-				$question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) );
453
+			foreach ($this->options() as $question_option) {
454
+				$question_option->duplicate(array('QST_ID' => $new_question->ID()));
455 455
 			}
456 456
 			return $new_question;
457 457
 		} else {
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @return int|float
465 465
 	 */
466 466
 	public function max() {
467
-		return $this->get( 'QST_max' );
467
+		return $this->get('QST_max');
468 468
 	}
469 469
 
470 470
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param int|float $new_max
473 473
 	 * @return void
474 474
 	 */
475
-	public function set_max( $new_max ) {
476
-		$this->set( 'QST_max', $new_max );
475
+	public function set_max($new_max) {
476
+		$this->set('QST_max', $new_max);
477 477
 	}
478 478
 
479 479
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 * @param array $input_constructor_args
486 486
 	 * @return EE_Form_Input_Base
487 487
 	 */
488
-	public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) {
488
+	public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) {
489 489
 		$identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
490 490
 
491 491
 		$input_constructor_args = array_merge( 
@@ -496,27 +496,27 @@  discard block
 block discarded – undo
496 496
 				),
497 497
 				$input_constructor_args
498 498
 			);
499
-		if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) {
500
-			$answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() );
499
+		if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
500
+			$answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
501 501
 		}
502 502
 		// has this question been answered ?
503
-		if ( $answer instanceof EE_Answer ) {
503
+		if ($answer instanceof EE_Answer) {
504 504
 			//answer gets htmlspecialchars called on it, undo that please
505 505
 			//beceause the form input's display strategy may call esc_attr too
506 506
 			//which also does html special characters
507 507
 			$values_with_html_special_chars = $answer->value();
508
-			if( is_array( $values_with_html_special_chars ) ) {
509
-				$default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars );
508
+			if (is_array($values_with_html_special_chars)) {
509
+				$default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
510 510
 			} else {
511
-				$default_value = htmlspecialchars_decode( $values_with_html_special_chars );
511
+				$default_value = htmlspecialchars_decode($values_with_html_special_chars);
512 512
 			}
513 513
 			$input_constructor_args['default'] = $default_value;
514 514
 		}
515
-		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() );
516
-		if( EEM_Question::instance()->question_type_is_in_category(  $this->type(), 'text' ) ) {
517
-			$input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy(
515
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
516
+		if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) {
517
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
518 518
 				null,
519
-				min( $max_max_for_question, $this->max() )
519
+				min($max_max_for_question, $this->max())
520 520
 			);
521 521
 		}
522 522
 		$input_constructor_args = apply_filters(
@@ -528,26 +528,26 @@  discard block
 block discarded – undo
528 528
 		);
529 529
 
530 530
 		$result = null;
531
-		switch ( $this->type() ) {
531
+		switch ($this->type()) {
532 532
 			// Text
533 533
 			case EEM_Question::QST_type_text :
534
-				if( $identifier == 'email' ){
535
-					$result = new EE_Email_Input( $input_constructor_args );
536
-				}else{
537
-					$result = new EE_Text_Input( $input_constructor_args );
534
+				if ($identifier == 'email') {
535
+					$result = new EE_Email_Input($input_constructor_args);
536
+				} else {
537
+					$result = new EE_Text_Input($input_constructor_args);
538 538
 				}
539 539
 				break;
540 540
 			// Textarea
541 541
 			case EEM_Question::QST_type_textarea :
542
-				$result = new EE_Text_Area_Input( $input_constructor_args );
542
+				$result = new EE_Text_Area_Input($input_constructor_args);
543 543
 				break;
544 544
 			// Radio Buttons
545 545
 			case EEM_Question::QST_type_radio :
546
-				$result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args );
546
+				$result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
547 547
 				break;
548 548
 			// Dropdown
549 549
 			case EEM_Question::QST_type_dropdown :
550
-				$result = new EE_Select_Input( $this->options(), $input_constructor_args );
550
+				$result = new EE_Select_Input($this->options(), $input_constructor_args);
551 551
 				break;
552 552
 			// State Dropdown
553 553
 			case EEM_Question::QST_type_state :
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 					$this,
558 558
 					$registration,
559 559
 					$answer
560
-				);				$result = new EE_State_Select_Input( $state_options, $input_constructor_args );
560
+				); $result = new EE_State_Select_Input($state_options, $input_constructor_args);
561 561
 				break;
562 562
 			// Country Dropdown
563 563
 			case EEM_Question::QST_type_country :
@@ -568,20 +568,20 @@  discard block
 block discarded – undo
568 568
 					$registration,
569 569
 					$answer
570 570
 				);
571
-				$result = new EE_Country_Select_Input( $country_options, $input_constructor_args );
571
+				$result = new EE_Country_Select_Input($country_options, $input_constructor_args);
572 572
 				break;
573 573
 			// Checkboxes
574 574
 			case EEM_Question::QST_type_checkbox :
575
-				$result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args );
575
+				$result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
576 576
 				break;
577 577
 			// Date
578 578
 			case EEM_Question::QST_type_date :
579
-				$result = new EE_Datepicker_Input( $input_constructor_args );
579
+				$result = new EE_Datepicker_Input($input_constructor_args);
580 580
 				break;
581 581
 			case EEM_Question::QST_type_html_textarea :
582
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy();
583
-				$input =  new EE_Text_Area_Input( $input_constructor_args );
584
-				$input->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' );
582
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
583
+				$input = new EE_Text_Area_Input($input_constructor_args);
584
+				$input->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
585 585
 				$result = $input;
586 586
 				break;
587 587
 			// fallback
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
 					$this,
594 594
 					$input_constructor_args
595 595
 				);
596
-				if( ! $default_input ){
597
-					$default_input = new EE_Text_Input( $input_constructor_args );
596
+				if ( ! $default_input) {
597
+					$default_input = new EE_Text_Input($input_constructor_args);
598 598
 				}
599 599
 				$result = $default_input;
600 600
 		}
601
-		return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer );
601
+		return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
602 602
 	}
603 603
 
604 604
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@
 block discarded – undo
533 533
 			case EEM_Question::QST_type_text :
534 534
 				if( $identifier == 'email' ){
535 535
 					$result = new EE_Email_Input( $input_constructor_args );
536
-				}else{
536
+				} else{
537 537
 					$result = new EE_Text_Input( $input_constructor_args );
538 538
 				}
539 539
 				break;
Please login to merge, or discard this patch.
strategies/validation/EE_Max_Length_Validation_Strategy.strategy.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,36 +8,36 @@
 block discarded – undo
8 8
  * @subpackage	Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php.
9 9
  * @author				Mike Nelson
10 10
  */
11
-class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base{
11
+class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base {
12 12
 
13 13
 	protected $_max_length;
14 14
 
15
-	public function __construct( $validation_error_message = NULL, $max_length = EE_INF ) {
15
+	public function __construct($validation_error_message = NULL, $max_length = EE_INF) {
16 16
 		$this->_max_length = $max_length;
17
-		if( $validation_error_message === null ) {
18
-			$validation_error_message = sprintf( __( 'Input is too long. Maximum number of characters is %1$s', 'event_espresso' ), $max_length );
17
+		if ($validation_error_message === null) {
18
+			$validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
19 19
 		}
20
-		parent::__construct( $validation_error_message );
20
+		parent::__construct($validation_error_message);
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @param $normalized_value
25 25
 	 */
26 26
 	public function validate($normalized_value) {
27
-		if( $this->_max_length !== EE_INF &&
27
+		if ($this->_max_length !== EE_INF &&
28 28
 				$normalized_value &&
29
-				is_string( $normalized_value ) &&
30
-				 strlen( $normalized_value ) > $this->_max_length){
31
-			throw new EE_Validation_Error( $this->get_validation_error_message(), 'maxlength' );
29
+				is_string($normalized_value) &&
30
+				 strlen($normalized_value) > $this->_max_length) {
31
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
32 32
 		}
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	 * @return array
37 37
 	 */
38
-	function get_jquery_validation_rule_array(){
39
-		if( $this->_max_length !== EE_INF ) {
40
-			return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
38
+	function get_jquery_validation_rule_array() {
39
+		if ($this->_max_length !== EE_INF) {
40
+			return array('maxlength'=> $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message()));
41 41
 		} else {
42 42
 			return array();
43 43
 		}
Please login to merge, or discard this patch.
libraries/form_sections/payment_methods/EE_Payment_Method_Form.form.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields.
5 5
  * Uses EEM_Payment_Method as the model
6 6
  */
7
-class EE_Payment_Method_Form extends EE_Model_Form_Section{
7
+class EE_Payment_Method_Form extends EE_Model_Form_Section {
8 8
 
9 9
 	/**
10 10
 	 * All the subsection inputs that correspond ot extra meta rows
@@ -39,37 +39,37 @@  discard block
 block discarded – undo
39 39
 	 *	@see EE_Model_Form_Section::__construct() for more
40 40
 	 * }
41 41
 	 */
42
-	public function __construct($options_array = array()){
42
+	public function __construct($options_array = array()) {
43 43
 		$this->_model = EEM_Payment_Method::instance();
44 44
 		$this->_options_array = $options_array;
45
-		if(isset($options_array['payment_method_type'])){
45
+		if (isset($options_array['payment_method_type'])) {
46 46
 			$this->_payment_method_type = $options_array['payment_method_type'];
47 47
 		}
48 48
 		$options_array = $this->_options_array;
49
-		if(isset($options_array['extra_meta_inputs'])){
50
-			$this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']);
49
+		if (isset($options_array['extra_meta_inputs'])) {
50
+			$this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']);
51 51
 		}
52
-		if($this->_extra_meta_inputs){
53
-			$this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs);
52
+		if ($this->_extra_meta_inputs) {
53
+			$this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs);
54 54
 		}
55 55
 		$this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input(
56
-			array( 'html_label_text'=>  __( 'Button URL', 'event_espresso' ))
56
+			array('html_label_text'=>  __('Button URL', 'event_espresso'))
57 57
 		);
58 58
 		$this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input(
59 59
 			EEM_Payment_Method::instance()->scopes(),
60
-			array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' ))
60
+			array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview'))
61 61
 		);
62 62
 		//setup the currency options
63 63
 		$this->_subsections['Currency'] = new EE_Select_Multi_Model_Input(
64
-			EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ),
64
+			EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type),
65 65
 			array(
66
-				'html_label_text'=>  __( 'Currencies Supported', 'event_espresso' ),
66
+				'html_label_text'=>  __('Currencies Supported', 'event_espresso'),
67 67
 				'required'=>TRUE
68 68
 			)
69 69
 		);
70
-		$this->_subsections['PMD_order'] = new EE_Text_Input( array(
71
-			'html_label_text' => __( 'Order', 'event_espresso' ),
72
-			'html_help_text' => __( 'Lowest numbers will be shown first', 'event_espresso' ),
70
+		$this->_subsections['PMD_order'] = new EE_Text_Input(array(
71
+			'html_label_text' => __('Order', 'event_espresso'),
72
+			'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'),
73 73
 			'normalization_strategy' => new EE_Int_Normalization(),
74 74
 			'validation_strategies' => array(
75 75
 				new EE_Int_Validation_Strategy()
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 	 * @param string 	$name
89 89
 	 * @throws EE_Error
90 90
 	 */
91
-	public function _construct_finalize( $parent_form_section, $name ) {
92
-		if( ! $this->_payment_method_type instanceof EE_PMT_Base ){
93
-			throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' )));
91
+	public function _construct_finalize($parent_form_section, $name) {
92
+		if ( ! $this->_payment_method_type instanceof EE_PMT_Base) {
93
+			throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso')));
94 94
 		}
95 95
 		//set the name of this form based on the payment method type
96
-		if( ! $this->_name && ! $name ){
97
-			$name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form";
96
+		if ( ! $this->_name && ! $name) {
97
+			$name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form";
98 98
 		}
99
-		parent::_construct_finalize( $parent_form_section, $name );
99
+		parent::_construct_finalize($parent_form_section, $name);
100 100
 	}
101 101
 
102 102
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * @param $payment_method_type
106 106
 	 * @throws EE_Error
107 107
 	 */
108
-	public function set_payment_method_type( $payment_method_type ){
109
-		if( ! $payment_method_type instanceof EE_PMT_Base){
108
+	public function set_payment_method_type($payment_method_type) {
109
+		if ( ! $payment_method_type instanceof EE_PMT_Base) {
110 110
 			throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso")));
111 111
 		}
112 112
 		$this->_payment_method_type = $payment_method_type;
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 * extends the model form section's save method to also save the extra meta field values
119 119
 	 * @return int ID of the payment method inserted, or true on update
120 120
 	 */
121
-	public function save(){
121
+	public function save() {
122 122
 		$parent_save_val = parent::save();
123
-		if( $this->_model_object && $this->_model_object->ID()){
124
-			foreach($this->_extra_meta_inputs as $input_name => $input){
123
+		if ($this->_model_object && $this->_model_object->ID()) {
124
+			foreach ($this->_extra_meta_inputs as $input_name => $input) {
125 125
 				$this->_model_object->update_extra_meta($input_name, $input->normalized_value());
126 126
 			}
127 127
 		}
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 		$model_obj = $this->_model->ensure_is_obj($model_obj);
139 139
 		parent::populate_model_obj($model_obj);
140 140
 		$extra_meta = $model_obj->all_extra_meta_array();
141
-		foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){
142
-			if(isset($extra_meta[$input_name])){
141
+		foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) {
142
+			if (isset($extra_meta[$input_name])) {
143 143
 				$extra_meta_input->set_default($extra_meta[$input_name]);
144 144
 			}
145 145
 		}
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 * gets the default name of this form section if none is specified
152 152
 	 * @return string
153 153
 	 */
154
-	protected function _set_default_name_if_empty(){
155
-		if( ! $this->_name ){
156
-			$default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
157
-			$this->_name =  $default_name;
154
+	protected function _set_default_name_if_empty() {
155
+		if ( ! $this->_name) {
156
+			$default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form";
157
+			$this->_name = $default_name;
158 158
 		}
159 159
 	}
160 160
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * Gets all the extra meta inputs in this form
165 165
 	 * @return EE_Form_Input_Base[]
166 166
 	 */
167
-	public function extra_meta_inputs(){
167
+	public function extra_meta_inputs() {
168 168
 		return $this->_extra_meta_inputs;
169 169
 	}
170 170
 }
Please login to merge, or discard this patch.
admin_pages/registration_form/Registration_Form_Admin_Page.core.php 2 patches
Braces   +9 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -330,14 +331,9 @@  discard block
 block discarded – undo
330 331
 			else if ( $fieldName == 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] )  )) {
331 332
 				$QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ;
332 333
 				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10));
333
-			}
334
-
335
-
336
-			else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
334
+			} else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
337 335
 				$set_column_values[$fieldName] = 0;
338
-			}
339
-
340
-			else if ( $fieldName == 'QST_max' ) {
336
+			} else if ( $fieldName == 'QST_max' ) {
341 337
 				$qst_system = EEM_Question::instance()->get_var(
342 338
 					array(
343 339
 						array(
@@ -390,7 +386,7 @@  discard block
 block discarded – undo
390 386
 			$question=$this->_question_model->get_one_by_ID($ID);
391 387
 			$additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID));
392 388
 			$this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
393
-		}else{
389
+		} else{
394 390
 			$question= EE_Question::new_instance();
395 391
 			$question->set_order_to_latest();
396 392
 			$this->_set_add_edit_form_tags('insert_question');
@@ -421,7 +417,7 @@  discard block
 block discarded – undo
421 417
 			$ID=$this->_question_model->insert($set_column_values);
422 418
 			$success = $ID ? true : false;
423 419
 			$action_desc = 'added';
424
-		}else{
420
+		} else{
425 421
 			$ID=absint($this->_req_data['QST_ID']);
426 422
 			$pk=$this->_question_model->primary_key_name();
427 423
 			$wheres=array($pk=>$ID);
@@ -442,7 +438,7 @@  discard block
 block discarded – undo
442 438
 					$option_req_index=$this->_get_option_req_data_index($option_ID);
443 439
 					if($option_req_index!==FALSE){
444 440
 						$option->save($this->_req_data['question_options'][$option_req_index]);
445
-					}else{
441
+					} else{
446 442
 						//not found, remove it
447 443
 						$option->delete();
448 444
 					}
@@ -519,7 +515,7 @@  discard block
 block discarded – undo
519 515
 						'QSG_name'=>array('LIKE',"%$search_string%"),
520 516
 						'QSG_desc'=>array('LIKE',"%$search_string%"))
521 517
 					);
522
-			}else{
518
+			} else{
523 519
 				$query_params[0]=array(
524 520
 					'QST_display_text'=>array('LIKE',"%$search_string%")
525 521
 					);
@@ -575,7 +571,7 @@  discard block
 block discarded – undo
575 571
 		if ($count){
576 572
 			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
577 573
 			$results = $QST->count($where);
578
-		}else{
574
+		} else{
579 575
 			$results = $QST->get_all($query_params);
580 576
 		}
581 577
 		return $results;
Please login to merge, or discard this patch.
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 
59 59
 
60 60
 
61
-	public function __construct( $routing = TRUE ) {
62
-		require_once( EE_MODELS . 'EEM_Question.model.php' );
63
-		require_once( EE_MODELS . 'EEM_Question_Group.model.php' );
64
-		$this->_question_model=  EEM_Question::instance();
65
-		$this->_question_group_model=EEM_Question_Group::instance();
66
-		parent::__construct( $routing );
61
+	public function __construct($routing = TRUE) {
62
+		require_once(EE_MODELS.'EEM_Question.model.php');
63
+		require_once(EE_MODELS.'EEM_Question_Group.model.php');
64
+		$this->_question_model = EEM_Question::instance();
65
+		$this->_question_group_model = EEM_Question_Group::instance();
66
+		parent::__construct($routing);
67 67
 	}
68 68
 
69 69
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 
99 99
 	protected function _set_page_routes() {
100
-		$qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0;
100
+		$qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
101 101
 		$this->_page_routes = array(
102 102
 			'default' => array(
103 103
 				'func' => '_questions_overview_list_table',
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 			'update_question' => array(
120 120
 				'func' => '_insert_or_update_question',
121
-				'args' => array('new_question' => FALSE ),
121
+				'args' => array('new_question' => FALSE),
122 122
 				'capability' => 'ee_edit_question',
123 123
 				'obj_id' => $qst_id,
124 124
 				'noheader' => TRUE,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 						'filename' => 'registration_form_questions_overview_views_bulk_actions_search'
154 154
 						)
155 155
 					),
156
-				'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'),
156
+				'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'),
157 157
 				'require_nonce' => FALSE,
158 158
 				'qtips' => array(
159 159
 					'EE_Registration_Form_Tips'
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 						'filename' => 'registration_form_question_groups'
173 173
 						),
174 174
 					),
175
-				'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'),
175
+				'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'),
176 176
 				'require_nonce' => FALSE
177 177
 				),
178 178
 
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 					'label' => __('Edit Question', 'event_espresso'),
182 182
 					'order' => 15,
183 183
 					'persistent' => FALSE,
184
-					'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url )  : $this->_admin_base_url
184
+					'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url
185 185
 					),
186
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
186
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
187 187
 				'help_tabs' => array(
188 188
 					'registration_form_edit_question_group_help_tab' => array(
189 189
 						'title' => __('Edit Question', 'event_espresso'),
190 190
 						'filename' => 'registration_form_edit_question'
191 191
 						),
192 192
 					),
193
-                'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'),
193
+                'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'),
194 194
 				'require_nonce' => FALSE
195 195
 				),
196 196
 			);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	//none of the below group are currently used for Event Categories
219 219
 	protected function _add_feature_pointers() {}
220 220
 	public function load_scripts_styles() {
221
-		wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION );
221
+		wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION);
222 222
 		wp_enqueue_style('espresso_registration');
223 223
 	}
224 224
 	public function admin_init() {}
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 
235 235
 	public function load_scripts_styles_add_question() {
236 236
 		$this->load_scripts_styles_forms();
237
-		wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE );
238
-		wp_enqueue_script( 'espresso_registration_form_single' );
237
+		wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
238
+		wp_enqueue_script('espresso_registration_form_single');
239 239
 	}
240 240
 	public function load_scripts_styles_edit_question() {
241 241
 		$this->load_scripts_styles_forms();
242
-		wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE );
243
-		wp_enqueue_script( 'espresso_registration_form_single' );
242
+		wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
243
+		wp_enqueue_script('espresso_registration_form_single');
244 244
 	}
245 245
 
246 246
 
247 247
 
248 248
 
249 249
 	public function recaptcha_info_help_tab() {
250
-		$template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php';
250
+		$template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php';
251 251
 		EEH_Template::display_template($template, array());
252 252
 	}
253 253
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 				)
280 280
 		);
281 281
 
282
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) {
282
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) {
283 283
 			$this->_views['trash'] = array(
284 284
 				'slug' => 'trash',
285 285
 				'label' => __('Trash', 'event_espresso'),
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	protected function _questions_groups_preview() {
299 299
 		$this->_admin_page_title = __('Question Groups (Preview)', 'event_espresso');
300
-		$this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />';
301
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso.  With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>';
302
-		$this->display_admin_caf_preview_page( 'question_groups_tab' );
300
+		$this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />';
301
+		$this->_template_args['preview_text'] = '<strong>'.__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso.  With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>';
302
+		$this->display_admin_caf_preview_page('question_groups_tab');
303 303
 	}
304 304
 
305 305
 
@@ -310,58 +310,58 @@  discard block
 block discarded – undo
310 310
 	 * @param \EEM_Base $model
311 311
 	 * @return array where each key is the name of a model's field/db column, and each value is its value.
312 312
 	 */
313
-	protected function _set_column_values_for(EEM_Base $model){
314
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
315
-		$set_column_values=array();
313
+	protected function _set_column_values_for(EEM_Base $model) {
314
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
315
+		$set_column_values = array();
316 316
 
317 317
 		//some initial checks for proper values.
318 318
 		//if QST_admin_only, then no matter what QST_required is we disable.
319
-		if ( !empty( $this->_req_data['QST_admin_only'] ) ) {
319
+		if ( ! empty($this->_req_data['QST_admin_only'])) {
320 320
 			$this->_req_data['QST_required'] = 0;
321 321
 		}
322
-		foreach($model->field_settings() as $fieldName=>$settings){
322
+		foreach ($model->field_settings() as $fieldName=>$settings) {
323 323
 			// basically if QSG_identifier is empty or not set
324
-			if ( $fieldName == 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) {
325
-				$QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ;
326
-				$set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid();
324
+			if ($fieldName == 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) {
325
+				$QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : '';
326
+				$set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid();
327 327
 //				dd($set_column_values);
328 328
 			}
329 329
 			//if the admin label is blank, use a slug version of the question text
330
-			else if ( $fieldName == 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] )  )) {
331
-				$QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ;
332
-				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10));
330
+			else if ($fieldName == 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) {
331
+				$QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : '';
332
+				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10));
333 333
 			}
334 334
 
335 335
 
336
-			else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
336
+			else if ($fieldName == 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) {
337 337
 				$set_column_values[$fieldName] = 0;
338 338
 			}
339 339
 
340
-			else if ( $fieldName == 'QST_max' ) {
340
+			else if ($fieldName == 'QST_max') {
341 341
 				$qst_system = EEM_Question::instance()->get_var(
342 342
 					array(
343 343
 						array(
344
-							'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0
344
+							'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0
345 345
 						)
346 346
 					),
347 347
 					'QST_system' );
348
-				$max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system );
349
-				if( empty( $this->_req_data[ 'QST_max' ] ) ||
350
-					 $this->_req_data[ 'QST_max' ] > $max_max ) {
351
-					$set_column_values[ $fieldName ] = $max_max;
348
+				$max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system);
349
+				if (empty($this->_req_data['QST_max']) ||
350
+					 $this->_req_data['QST_max'] > $max_max) {
351
+					$set_column_values[$fieldName] = $max_max;
352 352
 				}
353 353
 			}
354 354
 
355 355
 
356 356
 			//only add a property to the array if it's not null (otherwise the model should just use the default value)
357
-			if(
358
-				! isset( $set_column_values[ $fieldName ] ) &&
359
-				isset($this->_req_data[$fieldName] ) ){
360
-				$set_column_values[$fieldName]=$this->_req_data[$fieldName];
357
+			if (
358
+				! isset($set_column_values[$fieldName]) &&
359
+				isset($this->_req_data[$fieldName]) ) {
360
+				$set_column_values[$fieldName] = $this->_req_data[$fieldName];
361 361
 			}
362 362
 
363 363
 		}
364
-		return $set_column_values;//validation fo this data to be performed by the model before insertion.
364
+		return $set_column_values; //validation fo this data to be performed by the model before insertion.
365 365
 	}
366 366
 
367 367
 
@@ -379,30 +379,30 @@  discard block
 block discarded – undo
379 379
 	/**
380 380
 	 * @param string $action
381 381
 	 */
382
-	protected function _edit_question( $action= 'add' ) {
383
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
384
-		$ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE;
382
+	protected function _edit_question($action = 'add') {
383
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
384
+		$ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE;
385 385
 
386
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
386
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
387 387
 		// add PRC_ID to title if editing
388
-		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
389
-		if($ID){
390
-			$question=$this->_question_model->get_one_by_ID($ID);
391
-			$additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID));
388
+		$this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
389
+		if ($ID) {
390
+			$question = $this->_question_model->get_one_by_ID($ID);
391
+			$additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID));
392 392
 			$this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
393
-		}else{
394
-			$question= EE_Question::new_instance();
393
+		} else {
394
+			$question = EE_Question::new_instance();
395 395
 			$question->set_order_to_latest();
396 396
 			$this->_set_add_edit_form_tags('insert_question');
397 397
 		}
398
-		$question_types = $question->has_answers() ?  $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types();
399
-		$this->_template_args['QST_ID']=$ID;
400
-		$this->_template_args['question']=$question;
401
-		$this->_template_args['question_types']= $question_types;
402
-		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() );
398
+		$question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types();
399
+		$this->_template_args['QST_ID'] = $ID;
400
+		$this->_template_args['question'] = $question;
401
+		$this->_template_args['question_types'] = $question_types;
402
+		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID());
403 403
 
404
-		$this->_set_publish_post_box_vars( 'id', $ID );
405
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE );
404
+		$this->_set_publish_post_box_vars('id', $ID);
405
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE);
406 406
 
407 407
 		// the details template wrapper
408 408
 		$this->display_admin_page_with_sidebar();
@@ -414,58 +414,58 @@  discard block
 block discarded – undo
414 414
 	 * @param bool|true $new_question
415 415
 	 * @throws \EE_Error
416 416
 	 */
417
-	protected function _insert_or_update_question( $new_question = TRUE) {
418
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
419
-		$set_column_values=$this->_set_column_values_for($this->_question_model);
420
-		if($new_question){
421
-			$ID=$this->_question_model->insert($set_column_values);
417
+	protected function _insert_or_update_question($new_question = TRUE) {
418
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
419
+		$set_column_values = $this->_set_column_values_for($this->_question_model);
420
+		if ($new_question) {
421
+			$ID = $this->_question_model->insert($set_column_values);
422 422
 			$success = $ID ? true : false;
423 423
 			$action_desc = 'added';
424
-		}else{
425
-			$ID=absint($this->_req_data['QST_ID']);
426
-			$pk=$this->_question_model->primary_key_name();
427
-			$wheres=array($pk=>$ID);
424
+		} else {
425
+			$ID = absint($this->_req_data['QST_ID']);
426
+			$pk = $this->_question_model->primary_key_name();
427
+			$wheres = array($pk=>$ID);
428 428
 			unset($set_column_values[$pk]);
429
-			$success= $this->_question_model->update($set_column_values,array($wheres));
430
-			$action_desc='updated';
429
+			$success = $this->_question_model->update($set_column_values, array($wheres));
430
+			$action_desc = 'updated';
431 431
 		}
432 432
 
433
-		if ($ID){
433
+		if ($ID) {
434 434
 			//save the related options
435 435
 			//trash removed options, save old ones
436 436
 			//get list of all options
437 437
 			/** @type EE_Question $question */
438
-			$question=$this->_question_model->get_one_by_ID($ID);
439
-			$options=$question->options();
440
-			if(! empty($options)){
441
-				foreach($options as $option_ID=>$option){
442
-					$option_req_index=$this->_get_option_req_data_index($option_ID);
443
-					if($option_req_index!==FALSE){
438
+			$question = $this->_question_model->get_one_by_ID($ID);
439
+			$options = $question->options();
440
+			if ( ! empty($options)) {
441
+				foreach ($options as $option_ID=>$option) {
442
+					$option_req_index = $this->_get_option_req_data_index($option_ID);
443
+					if ($option_req_index !== FALSE) {
444 444
 						$option->save($this->_req_data['question_options'][$option_req_index]);
445
-					}else{
445
+					} else {
446 446
 						//not found, remove it
447 447
 						$option->delete();
448 448
 					}
449 449
 				}
450 450
 			}
451 451
 			//save new related options
452
-			foreach($this->_req_data['question_options'] as $index=>$option_req_data){
453
-				if( empty($option_req_data['QSO_ID'] ) && (  ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it!
454
-					if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === ''  ){
455
-						$option_req_data['QSO_value']=$option_req_data['QSO_desc'];
452
+			foreach ($this->_req_data['question_options'] as $index=>$option_req_data) {
453
+				if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it!
454
+					if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') {
455
+						$option_req_data['QSO_value'] = $option_req_data['QSO_desc'];
456 456
 					}
457
-					$new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID()));
457
+					$new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID()));
458 458
 					$new_option->save();
459 459
 				}
460 460
 			}
461 461
 		}
462
-		$query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID );
463
-		if ( $success !== FALSE ) {
464
-			$msg = $new_question ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() );
465
-			EE_Error::add_success( $msg );
462
+		$query_args = array('action' => 'edit_question', 'QST_ID' => $ID);
463
+		if ($success !== FALSE) {
464
+			$msg = $new_question ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name());
465
+			EE_Error::add_success($msg);
466 466
 		}
467 467
 
468
-		$this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE);
468
+		$this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE);
469 469
 	}
470 470
 
471 471
 
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	 * @param int $ID of the question option to find
479 479
 	 * @return int index in question_options array if successful, FALSE if unsuccessful
480 480
 	 */
481
-	protected function _get_option_req_data_index($ID){
482
-		$req_data_for_question_options=$this->_req_data['question_options'];
483
-		foreach($req_data_for_question_options as $num=>$option_data){
484
-			if(array_key_exists('QSO_ID',$option_data) && intval($option_data['QSO_ID'])==$ID){
481
+	protected function _get_option_req_data_index($ID) {
482
+		$req_data_for_question_options = $this->_req_data['question_options'];
483
+		foreach ($req_data_for_question_options as $num=>$option_data) {
484
+			if (array_key_exists('QSO_ID', $option_data) && intval($option_data['QSO_ID']) == $ID) {
485 485
 				return $num;
486 486
 			}
487 487
 		}
@@ -503,25 +503,25 @@  discard block
 block discarded – undo
503 503
 	 * @param int      $current_page
504 504
 	 * @return array lik EEM_Base::get_all's $query_params parameter
505 505
 	 */
506
-	protected function get_query_params($model, $per_page=10,$current_page=10){
506
+	protected function get_query_params($model, $per_page = 10, $current_page = 10) {
507 507
 		$query_params = array();
508
-		$offset=($current_page-1)*$per_page;
509
-		$query_params['limit']=array($offset,$per_page);
510
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
508
+		$offset = ($current_page - 1) * $per_page;
509
+		$query_params['limit'] = array($offset, $per_page);
510
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
511 511
 		$orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order';
512 512
 		$field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby'];
513
-		$query_params['order_by']=array( $field_to_order_by => $order );
514
-		$search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null;
515
-		if(! empty($search_string)){
516
-			if($model instanceof EEM_Question_Group){
517
-				$query_params[0]=array(
513
+		$query_params['order_by'] = array($field_to_order_by => $order);
514
+		$search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null;
515
+		if ( ! empty($search_string)) {
516
+			if ($model instanceof EEM_Question_Group) {
517
+				$query_params[0] = array(
518 518
 					'OR'=>array(
519
-						'QSG_name'=>array('LIKE',"%$search_string%"),
520
-						'QSG_desc'=>array('LIKE',"%$search_string%"))
519
+						'QSG_name'=>array('LIKE', "%$search_string%"),
520
+						'QSG_desc'=>array('LIKE', "%$search_string%"))
521 521
 					);
522
-			}else{
523
-				$query_params[0]=array(
524
-					'QST_display_text'=>array('LIKE',"%$search_string%")
522
+			} else {
523
+				$query_params[0] = array(
524
+					'QST_display_text'=>array('LIKE', "%$search_string%")
525 525
 					);
526 526
 			}
527 527
 		}
@@ -569,13 +569,13 @@  discard block
 block discarded – undo
569 569
 	 * @param bool|false $count
570 570
 	 * @return \EE_Soft_Delete_Base_Class[]|int
571 571
 	 */
572
-	public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) {
572
+	public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) {
573 573
 		$QST = EEM_Question::instance();
574 574
 		$query_params = $this->get_query_params($QST, $per_page, $current_page);
575
-		if ($count){
576
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
575
+		if ($count) {
576
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
577 577
 			$results = $QST->count($where);
578
-		}else{
578
+		} else {
579 579
 			$results = $QST->get_all($query_params);
580 580
 		}
581 581
 		return $results;
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 * @param bool|false $count
591 591
 	 * @return \EE_Soft_Delete_Base_Class[]|int
592 592
 	 */
593
-	public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) {
594
-		$query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page);
595
-		$where        = isset( $query_params[0] ) ? array($query_params[0]) : array();
596
-		$questions    =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
593
+	public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) {
594
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
595
+		$where        = isset($query_params[0]) ? array($query_params[0]) : array();
596
+		$questions    = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
597 597
 		return $questions;
598 598
 	}
599 599
 
@@ -605,11 +605,11 @@  discard block
 block discarded – undo
605 605
 	 * @param bool|false $count
606 606
 	 * @return \EE_Soft_Delete_Base_Class[]
607 607
 	 */
608
-	public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
608
+	public function get_question_groups($per_page, $current_page = 1, $count = FALSE) {
609 609
 		/** @type EEM_Question_Group $questionGroupModel */
610
-		$questionGroupModel=EEM_Question_Group::instance();
611
-		$query_params=$this->get_query_params( $questionGroupModel, $per_page, $current_page );
612
-		$questionGroups=$questionGroupModel->get_all($query_params);//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
610
+		$questionGroupModel = EEM_Question_Group::instance();
611
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
612
+		$questionGroups = $questionGroupModel->get_all($query_params); //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
613 613
 		return $questionGroups;
614 614
 	}
615 615
 
@@ -626,36 +626,36 @@  discard block
 block discarded – undo
626 626
 
627 627
 		$this->_template_args['values'] = $this->_yes_no_values;
628 628
 
629
-		$this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE;
630
-		$this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': '';
629
+		$this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE;
630
+		$this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : '';
631 631
 
632
-		$this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '';
633
-		$this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '';
634
-		$this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500;
632
+		$this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : '';
633
+		$this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : '';
634
+		$this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500;
635 635
 
636 636
 		$this->_template_args['recaptcha_theme_options'] = array(
637
-				array('id'  => 'red','text'=> __('Red', 'event_espresso')),
638
-				array('id'  => 'white','text'=> __('White', 'event_espresso')),
639
-				array('id'  => 'blackglass','text'=> __('Blackglass', 'event_espresso')),
640
-				array('id'  => 'clean','text'=> __('Clean', 'event_espresso'))
637
+				array('id'  => 'red', 'text'=> __('Red', 'event_espresso')),
638
+				array('id'  => 'white', 'text'=> __('White', 'event_espresso')),
639
+				array('id'  => 'blackglass', 'text'=> __('Blackglass', 'event_espresso')),
640
+				array('id'  => 'clean', 'text'=> __('Clean', 'event_espresso'))
641 641
 			);
642
-		$this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean';
642
+		$this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean';
643 643
 
644 644
 		$this->_template_args['recaptcha_language_options'] = array(
645
-				array('id'  => 'en','text'=> __('English', 'event_espresso')),
646
-				array('id'  => 'es','text'=> __('Spanish', 'event_espresso')),
647
-				array('id'  => 'nl','text'=> __('Dutch', 'event_espresso')),
648
-				array('id'  => 'fr','text'=> __('French', 'event_espresso')),
649
-				array('id'  => 'de','text'=> __('German', 'event_espresso')),
650
-				array('id'  => 'pt','text'=> __('Portuguese', 'event_espresso')),
651
-				array('id'  => 'ru','text'=> __('Russian', 'event_espresso')),
652
-				array('id'  => 'tr','text'=> __('Turkish', 'event_espresso'))
645
+				array('id'  => 'en', 'text'=> __('English', 'event_espresso')),
646
+				array('id'  => 'es', 'text'=> __('Spanish', 'event_espresso')),
647
+				array('id'  => 'nl', 'text'=> __('Dutch', 'event_espresso')),
648
+				array('id'  => 'fr', 'text'=> __('French', 'event_espresso')),
649
+				array('id'  => 'de', 'text'=> __('German', 'event_espresso')),
650
+				array('id'  => 'pt', 'text'=> __('Portuguese', 'event_espresso')),
651
+				array('id'  => 'ru', 'text'=> __('Russian', 'event_espresso')),
652
+				array('id'  => 'tr', 'text'=> __('Turkish', 'event_espresso'))
653 653
 			);
654
-		$this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en';
654
+		$this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en';
655 655
 
656
-		$this->_set_add_edit_form_tags( 'update_reg_form_settings' );
657
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
658
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE );
656
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
657
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
658
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE);
659 659
 		$this->display_admin_page_with_sidebar();
660 660
 	}
661 661
 
Please login to merge, or discard this patch.