Completed
Branch BUG-9529-email-validation-sett... (1ebf1c)
by
unknown
523:24 queued 507:47
created
admin_pages/registration_form/Registration_Form_Admin_Page.core.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *_question_model EEM_Question model instance (for queries)
51 51
 	 *
52 52
 	 * @var EEM_Question $_question_model;
53
- */
53
+	 */
54 54
 	protected $_question_model;
55 55
 
56 56
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 					),
152 152
 				'list_table' => 'Registration_Form_Questions_Admin_List_Table',
153 153
 				'metaboxes' => $this->_default_espresso_metaboxes,
154
-                'help_tabs' => array(
154
+				'help_tabs' => array(
155 155
 					'registration_form_questions_overview_help_tab' => array(
156 156
 						'title' => __('Questions Overview', 'event_espresso'),
157 157
 						'filename' => 'registration_form_questions_overview'
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 						'filename' => 'registration_form_edit_question'
203 203
 						),
204 204
 					),
205
-                'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'),
205
+				'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'),
206 206
 				'require_nonce' => FALSE
207 207
 				),
208 208
 			);
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 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
 /**
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	 * 		@param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
69 69
 	 * 		@access public
70 70
 	 */
71
-	public function __construct( $routing = TRUE ) {
72
-		require_once( EE_MODELS . 'EEM_Question.model.php' );
73
-		require_once( EE_MODELS . 'EEM_Question_Group.model.php' );
74
-		$this->_question_model=  EEM_Question::instance();
75
-		$this->_question_group_model=EEM_Question_Group::instance();
76
-		parent::__construct( $routing );
71
+	public function __construct($routing = TRUE) {
72
+		require_once(EE_MODELS.'EEM_Question.model.php');
73
+		require_once(EE_MODELS.'EEM_Question_Group.model.php');
74
+		$this->_question_model = EEM_Question::instance();
75
+		$this->_question_group_model = EEM_Question_Group::instance();
76
+		parent::__construct($routing);
77 77
 	}
78 78
 
79 79
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 *_set_page_routes
110 110
 	 */
111 111
 	protected function _set_page_routes() {
112
-		$qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0;
112
+		$qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
113 113
 		$this->_page_routes = array(
114 114
 			'default' => array(
115 115
 				'func' => '_questions_overview_list_table',
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 			'update_question' => array(
132 132
 				'func' => '_insert_or_update_question',
133
-				'args' => array('new_question' => FALSE ),
133
+				'args' => array('new_question' => FALSE),
134 134
 				'capability' => 'ee_edit_question',
135 135
 				'obj_id' => $qst_id,
136 136
 				'noheader' => TRUE,
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 						'filename' => 'registration_form_questions_overview_views_bulk_actions_search'
166 166
 						)
167 167
 					),
168
-				'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'),
168
+				'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'),
169 169
 				'require_nonce' => FALSE,
170 170
 				'qtips' => array(
171 171
 					'EE_Registration_Form_Tips'
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 						'filename' => 'registration_form_question_groups'
185 185
 						),
186 186
 					),
187
-				'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'),
187
+				'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'),
188 188
 				'require_nonce' => FALSE
189 189
 				),
190 190
 
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
 					'label' => __('Edit Question', 'event_espresso'),
194 194
 					'order' => 15,
195 195
 					'persistent' => FALSE,
196
-					'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
196
+					'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
197 197
 					),
198
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
198
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
199 199
 				'help_tabs' => array(
200 200
 					'registration_form_edit_question_group_help_tab' => array(
201 201
 						'title' => __('Edit Question', 'event_espresso'),
202 202
 						'filename' => 'registration_form_edit_question'
203 203
 						),
204 204
 					),
205
-                'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'),
205
+                'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'),
206 206
 				'require_nonce' => FALSE
207 207
 				),
208 208
 			);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	//none of the below group are currently used for Event Categories
231 231
 	protected function _add_feature_pointers() {}
232 232
 	public function load_scripts_styles() {
233
-		wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION );
233
+		wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION);
234 234
 		wp_enqueue_style('espresso_registration');
235 235
 	}
236 236
 	public function admin_init() {}
@@ -246,20 +246,20 @@  discard block
 block discarded – undo
246 246
 
247 247
 	public function load_scripts_styles_add_question() {
248 248
 		$this->load_scripts_styles_forms();
249
-		wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE );
250
-		wp_enqueue_script( 'espresso_registration_form_single' );
249
+		wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
250
+		wp_enqueue_script('espresso_registration_form_single');
251 251
 	}
252 252
 	public function load_scripts_styles_edit_question() {
253 253
 		$this->load_scripts_styles_forms();
254
-		wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE );
255
-		wp_enqueue_script( 'espresso_registration_form_single' );
254
+		wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
255
+		wp_enqueue_script('espresso_registration_form_single');
256 256
 	}
257 257
 
258 258
 
259 259
 
260 260
 
261 261
 	public function recaptcha_info_help_tab() {
262
-		$template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php';
262
+		$template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php';
263 263
 		EEH_Template::display_template($template, array());
264 264
 	}
265 265
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 				)
292 292
 		);
293 293
 
294
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) {
294
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) {
295 295
 			$this->_views['trash'] = array(
296 296
 				'slug' => 'trash',
297 297
 				'label' => __('Trash', 'event_espresso'),
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	protected function _questions_groups_preview() {
311 311
 		$this->_admin_page_title = __('Question Groups (Preview)', 'event_espresso');
312
-		$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' ) . '" />';
313
-		$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>';
314
-		$this->display_admin_caf_preview_page( 'question_groups_tab' );
312
+		$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').'" />';
313
+		$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>';
314
+		$this->display_admin_caf_preview_page('question_groups_tab');
315 315
 	}
316 316
 
317 317
 
@@ -322,58 +322,58 @@  discard block
 block discarded – undo
322 322
 	 * @param \EEM_Base $model
323 323
 	 * @return array where each key is the name of a model's field/db column, and each value is its value.
324 324
 	 */
325
-	protected function _set_column_values_for(EEM_Base $model){
326
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
327
-		$set_column_values=array();
325
+	protected function _set_column_values_for(EEM_Base $model) {
326
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
327
+		$set_column_values = array();
328 328
 
329 329
 		//some initial checks for proper values.
330 330
 		//if QST_admin_only, then no matter what QST_required is we disable.
331
-		if ( !empty( $this->_req_data['QST_admin_only'] ) ) {
331
+		if ( ! empty($this->_req_data['QST_admin_only'])) {
332 332
 			$this->_req_data['QST_required'] = 0;
333 333
 		}
334
-		foreach($model->field_settings() as $fieldName=>$settings){
334
+		foreach ($model->field_settings() as $fieldName=>$settings) {
335 335
 			// basically if QSG_identifier is empty or not set
336
-			if ( $fieldName === 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) {
337
-				$QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ;
338
-				$set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid( '', true );
336
+			if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) {
337
+				$QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : '';
338
+				$set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true);
339 339
 //				dd($set_column_values);
340 340
 			}
341 341
 			//if the admin label is blank, use a slug version of the question text
342
-			else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] )  )) {
343
-				$QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ;
344
-				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10));
342
+			else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) {
343
+				$QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : '';
344
+				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10));
345 345
 			}
346 346
 
347 347
 
348
-			else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
348
+			else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) {
349 349
 				$set_column_values[$fieldName] = 0;
350 350
 			}
351 351
 
352
-			else if ( $fieldName === 'QST_max' ) {
352
+			else if ($fieldName === 'QST_max') {
353 353
 				$qst_system = EEM_Question::instance()->get_var(
354 354
 					array(
355 355
 						array(
356
-							'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0
356
+							'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0
357 357
 						)
358 358
 					),
359 359
 					'QST_system' );
360
-				$max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system );
361
-				if( empty( $this->_req_data[ 'QST_max' ] ) ||
362
-					 $this->_req_data[ 'QST_max' ] > $max_max ) {
363
-					$set_column_values[ $fieldName ] = $max_max;
360
+				$max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system);
361
+				if (empty($this->_req_data['QST_max']) ||
362
+					 $this->_req_data['QST_max'] > $max_max) {
363
+					$set_column_values[$fieldName] = $max_max;
364 364
 				}
365 365
 			}
366 366
 
367 367
 
368 368
 			//only add a property to the array if it's not null (otherwise the model should just use the default value)
369
-			if(
370
-				! isset( $set_column_values[ $fieldName ] ) &&
371
-				isset($this->_req_data[$fieldName] ) ){
372
-				$set_column_values[$fieldName]=$this->_req_data[$fieldName];
369
+			if (
370
+				! isset($set_column_values[$fieldName]) &&
371
+				isset($this->_req_data[$fieldName]) ) {
372
+				$set_column_values[$fieldName] = $this->_req_data[$fieldName];
373 373
 			}
374 374
 
375 375
 		}
376
-		return $set_column_values;//validation fo this data to be performed by the model before insertion.
376
+		return $set_column_values; //validation fo this data to be performed by the model before insertion.
377 377
 	}
378 378
 
379 379
 
@@ -392,29 +392,29 @@  discard block
 block discarded – undo
392 392
 	 * _edit_question
393 393
 	 */
394 394
 	protected function _edit_question() {
395
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
396
-		$ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE;
395
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
396
+		$ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE;
397 397
 
398
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
398
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
399 399
 		// add PRC_ID to title if editing
400
-		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
401
-		if($ID){
402
-			$question=$this->_question_model->get_one_by_ID($ID);
403
-			$additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID));
400
+		$this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
401
+		if ($ID) {
402
+			$question = $this->_question_model->get_one_by_ID($ID);
403
+			$additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID));
404 404
 			$this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
405
-		}else{
406
-			$question= EE_Question::new_instance();
405
+		} else {
406
+			$question = EE_Question::new_instance();
407 407
 			$question->set_order_to_latest();
408 408
 			$this->_set_add_edit_form_tags('insert_question');
409 409
 		}
410
-		$question_types = $question->has_answers() ?  $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types();
411
-		$this->_template_args['QST_ID']=$ID;
412
-		$this->_template_args['question']=$question;
413
-		$this->_template_args['question_types']= $question_types;
414
-		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() );
410
+		$question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types();
411
+		$this->_template_args['QST_ID'] = $ID;
412
+		$this->_template_args['question'] = $question;
413
+		$this->_template_args['question_types'] = $question_types;
414
+		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID());
415 415
 
416
-		$this->_set_publish_post_box_vars( 'id', $ID );
417
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE );
416
+		$this->_set_publish_post_box_vars('id', $ID);
417
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE);
418 418
 
419 419
 		// the details template wrapper
420 420
 		$this->display_admin_page_with_sidebar();
@@ -426,58 +426,58 @@  discard block
 block discarded – undo
426 426
 	 * @param bool|true $new_question
427 427
 	 * @throws \EE_Error
428 428
 	 */
429
-	protected function _insert_or_update_question( $new_question = TRUE) {
430
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
431
-		$set_column_values=$this->_set_column_values_for($this->_question_model);
432
-		if($new_question){
433
-			$ID=$this->_question_model->insert($set_column_values);
429
+	protected function _insert_or_update_question($new_question = TRUE) {
430
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
431
+		$set_column_values = $this->_set_column_values_for($this->_question_model);
432
+		if ($new_question) {
433
+			$ID = $this->_question_model->insert($set_column_values);
434 434
 			$success = $ID ? true : false;
435 435
 			$action_desc = 'added';
436
-		}else{
437
-			$ID=absint($this->_req_data['QST_ID']);
438
-			$pk=$this->_question_model->primary_key_name();
439
-			$wheres=array($pk=>$ID);
436
+		} else {
437
+			$ID = absint($this->_req_data['QST_ID']);
438
+			$pk = $this->_question_model->primary_key_name();
439
+			$wheres = array($pk=>$ID);
440 440
 			unset($set_column_values[$pk]);
441
-			$success= $this->_question_model->update($set_column_values,array($wheres));
442
-			$action_desc='updated';
441
+			$success = $this->_question_model->update($set_column_values, array($wheres));
442
+			$action_desc = 'updated';
443 443
 		}
444 444
 
445
-		if ($ID){
445
+		if ($ID) {
446 446
 			//save the related options
447 447
 			//trash removed options, save old ones
448 448
 			//get list of all options
449 449
 			/** @type EE_Question $question */
450
-			$question=$this->_question_model->get_one_by_ID($ID);
451
-			$options=$question->options();
452
-			if(! empty($options)){
453
-				foreach($options as $option_ID=>$option){
454
-					$option_req_index=$this->_get_option_req_data_index($option_ID);
455
-					if($option_req_index!==FALSE){
450
+			$question = $this->_question_model->get_one_by_ID($ID);
451
+			$options = $question->options();
452
+			if ( ! empty($options)) {
453
+				foreach ($options as $option_ID=>$option) {
454
+					$option_req_index = $this->_get_option_req_data_index($option_ID);
455
+					if ($option_req_index !== FALSE) {
456 456
 						$option->save($this->_req_data['question_options'][$option_req_index]);
457
-					}else{
457
+					} else {
458 458
 						//not found, remove it
459 459
 						$option->delete();
460 460
 					}
461 461
 				}
462 462
 			}
463 463
 			//save new related options
464
-			foreach($this->_req_data['question_options'] as $index=>$option_req_data){
465
-				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!
466
-					if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === ''  ){
467
-						$option_req_data['QSO_value']=$option_req_data['QSO_desc'];
464
+			foreach ($this->_req_data['question_options'] as $index=>$option_req_data) {
465
+				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!
466
+					if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') {
467
+						$option_req_data['QSO_value'] = $option_req_data['QSO_desc'];
468 468
 					}
469
-					$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()));
469
+					$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()));
470 470
 					$new_option->save();
471 471
 				}
472 472
 			}
473 473
 		}
474
-		$query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID );
475
-		if ( $success !== FALSE ) {
476
-			$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() );
477
-			EE_Error::add_success( $msg );
474
+		$query_args = array('action' => 'edit_question', 'QST_ID' => $ID);
475
+		if ($success !== FALSE) {
476
+			$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());
477
+			EE_Error::add_success($msg);
478 478
 		}
479 479
 
480
-		$this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE);
480
+		$this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE);
481 481
 	}
482 482
 
483 483
 
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 	 * @param int $ID of the question option to find
491 491
 	 * @return int index in question_options array if successful, FALSE if unsuccessful
492 492
 	 */
493
-	protected function _get_option_req_data_index($ID){
494
-		$req_data_for_question_options=$this->_req_data['question_options'];
495
-		foreach($req_data_for_question_options as $num=>$option_data){
496
-			if( array_key_exists('QSO_ID',$option_data) && (int)$option_data['QSO_ID'] === $ID ){
493
+	protected function _get_option_req_data_index($ID) {
494
+		$req_data_for_question_options = $this->_req_data['question_options'];
495
+		foreach ($req_data_for_question_options as $num=>$option_data) {
496
+			if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) {
497 497
 				return $num;
498 498
 			}
499 499
 		}
@@ -515,25 +515,25 @@  discard block
 block discarded – undo
515 515
 	 * @param int      $current_page
516 516
 	 * @return array lik EEM_Base::get_all's $query_params parameter
517 517
 	 */
518
-	protected function get_query_params($model, $per_page=10,$current_page=10){
518
+	protected function get_query_params($model, $per_page = 10, $current_page = 10) {
519 519
 		$query_params = array();
520
-		$offset=($current_page-1)*$per_page;
521
-		$query_params['limit']=array($offset,$per_page);
522
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
520
+		$offset = ($current_page - 1) * $per_page;
521
+		$query_params['limit'] = array($offset, $per_page);
522
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
523 523
 		$orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order';
524 524
 		$field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby'];
525
-		$query_params['order_by']=array( $field_to_order_by => $order );
526
-		$search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null;
527
-		if(! empty($search_string)){
528
-			if($model instanceof EEM_Question_Group){
529
-				$query_params[0]=array(
525
+		$query_params['order_by'] = array($field_to_order_by => $order);
526
+		$search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null;
527
+		if ( ! empty($search_string)) {
528
+			if ($model instanceof EEM_Question_Group) {
529
+				$query_params[0] = array(
530 530
 					'OR'=>array(
531
-						'QSG_name'=>array('LIKE',"%$search_string%"),
532
-						'QSG_desc'=>array('LIKE',"%$search_string%"))
531
+						'QSG_name'=>array('LIKE', "%$search_string%"),
532
+						'QSG_desc'=>array('LIKE', "%$search_string%"))
533 533
 					);
534
-			}else{
535
-				$query_params[0]=array(
536
-					'QST_display_text'=>array('LIKE',"%$search_string%")
534
+			} else {
535
+				$query_params[0] = array(
536
+					'QST_display_text'=>array('LIKE', "%$search_string%")
537 537
 					);
538 538
 			}
539 539
 		}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 * @param bool|false $count
582 582
 	 * @return \EE_Soft_Delete_Base_Class[]|int
583 583
 	 */
584
-	public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) {
584
+	public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) {
585 585
 		$QST = EEM_Question::instance();
586 586
 		$query_params = $this->get_query_params($QST, $per_page, $current_page);
587
-		if ($count){
588
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
587
+		if ($count) {
588
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
589 589
 			$results = $QST->count($where);
590
-		}else{
590
+		} else {
591 591
 			$results = $QST->get_all($query_params);
592 592
 		}
593 593
 		return $results;
@@ -602,10 +602,10 @@  discard block
 block discarded – undo
602 602
 	 * @param bool|false $count
603 603
 	 * @return \EE_Soft_Delete_Base_Class[]|int
604 604
 	 */
605
-	public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) {
606
-		$query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page);
607
-		$where        = isset( $query_params[0] ) ? array($query_params[0]) : array();
608
-		$questions    =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
605
+	public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) {
606
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
607
+		$where        = isset($query_params[0]) ? array($query_params[0]) : array();
608
+		$questions    = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
609 609
 		return $questions;
610 610
 	}
611 611
 
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 	 * @param bool|false $count
618 618
 	 * @return \EE_Soft_Delete_Base_Class[]
619 619
 	 */
620
-	public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
620
+	public function get_question_groups($per_page, $current_page = 1, $count = FALSE) {
621 621
 		/** @type EEM_Question_Group $questionGroupModel */
622 622
 		$questionGroupModel = EEM_Question_Group::instance();
623 623
 		//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
624 624
 		return $questionGroupModel->get_all(
625
-			$this->get_query_params( $questionGroupModel, $per_page, $current_page )
625
+			$this->get_query_params($questionGroupModel, $per_page, $current_page)
626 626
 		);
627 627
 	}
628 628
 
@@ -639,36 +639,36 @@  discard block
 block discarded – undo
639 639
 
640 640
 		$this->_template_args['values'] = $this->_yes_no_values;
641 641
 
642
-		$this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE;
643
-		$this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': '';
642
+		$this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE;
643
+		$this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : '';
644 644
 
645
-		$this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '';
646
-		$this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '';
647
-		$this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500;
645
+		$this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : '';
646
+		$this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : '';
647
+		$this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500;
648 648
 
649 649
 		$this->_template_args['recaptcha_theme_options'] = array(
650
-				array('id'  => 'red','text'=> __('Red', 'event_espresso')),
651
-				array('id'  => 'white','text'=> __('White', 'event_espresso')),
652
-				array('id'  => 'blackglass','text'=> __('Blackglass', 'event_espresso')),
653
-				array('id'  => 'clean','text'=> __('Clean', 'event_espresso'))
650
+				array('id'  => 'red', 'text'=> __('Red', 'event_espresso')),
651
+				array('id'  => 'white', 'text'=> __('White', 'event_espresso')),
652
+				array('id'  => 'blackglass', 'text'=> __('Blackglass', 'event_espresso')),
653
+				array('id'  => 'clean', 'text'=> __('Clean', 'event_espresso'))
654 654
 			);
655
-		$this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean';
655
+		$this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean';
656 656
 
657 657
 		$this->_template_args['recaptcha_language_options'] = array(
658
-				array('id'  => 'en','text'=> __('English', 'event_espresso')),
659
-				array('id'  => 'es','text'=> __('Spanish', 'event_espresso')),
660
-				array('id'  => 'nl','text'=> __('Dutch', 'event_espresso')),
661
-				array('id'  => 'fr','text'=> __('French', 'event_espresso')),
662
-				array('id'  => 'de','text'=> __('German', 'event_espresso')),
663
-				array('id'  => 'pt','text'=> __('Portuguese', 'event_espresso')),
664
-				array('id'  => 'ru','text'=> __('Russian', 'event_espresso')),
665
-				array('id'  => 'tr','text'=> __('Turkish', 'event_espresso'))
658
+				array('id'  => 'en', 'text'=> __('English', 'event_espresso')),
659
+				array('id'  => 'es', 'text'=> __('Spanish', 'event_espresso')),
660
+				array('id'  => 'nl', 'text'=> __('Dutch', 'event_espresso')),
661
+				array('id'  => 'fr', 'text'=> __('French', 'event_espresso')),
662
+				array('id'  => 'de', 'text'=> __('German', 'event_espresso')),
663
+				array('id'  => 'pt', 'text'=> __('Portuguese', 'event_espresso')),
664
+				array('id'  => 'ru', 'text'=> __('Russian', 'event_espresso')),
665
+				array('id'  => 'tr', 'text'=> __('Turkish', 'event_espresso'))
666 666
 			);
667
-		$this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en';
667
+		$this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en';
668 668
 
669
-		$this->_set_add_edit_form_tags( 'update_reg_form_settings' );
670
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
671
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE );
669
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
670
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
671
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE);
672 672
 		$this->display_admin_page_with_sidebar();
673 673
 	}
674 674
 
Please login to merge, or discard this patch.
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
@@ -342,14 +343,9 @@  discard block
 block discarded – undo
342 343
 			else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] )  )) {
343 344
 				$QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ;
344 345
 				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10));
345
-			}
346
-
347
-
348
-			else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
346
+			} else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
349 347
 				$set_column_values[$fieldName] = 0;
350
-			}
351
-
352
-			else if ( $fieldName === 'QST_max' ) {
348
+			} else if ( $fieldName === 'QST_max' ) {
353 349
 				$qst_system = EEM_Question::instance()->get_var(
354 350
 					array(
355 351
 						array(
@@ -402,7 +398,7 @@  discard block
 block discarded – undo
402 398
 			$question=$this->_question_model->get_one_by_ID($ID);
403 399
 			$additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID));
404 400
 			$this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
405
-		}else{
401
+		} else{
406 402
 			$question= EE_Question::new_instance();
407 403
 			$question->set_order_to_latest();
408 404
 			$this->_set_add_edit_form_tags('insert_question');
@@ -433,7 +429,7 @@  discard block
 block discarded – undo
433 429
 			$ID=$this->_question_model->insert($set_column_values);
434 430
 			$success = $ID ? true : false;
435 431
 			$action_desc = 'added';
436
-		}else{
432
+		} else{
437 433
 			$ID=absint($this->_req_data['QST_ID']);
438 434
 			$pk=$this->_question_model->primary_key_name();
439 435
 			$wheres=array($pk=>$ID);
@@ -454,7 +450,7 @@  discard block
 block discarded – undo
454 450
 					$option_req_index=$this->_get_option_req_data_index($option_ID);
455 451
 					if($option_req_index!==FALSE){
456 452
 						$option->save($this->_req_data['question_options'][$option_req_index]);
457
-					}else{
453
+					} else{
458 454
 						//not found, remove it
459 455
 						$option->delete();
460 456
 					}
@@ -531,7 +527,7 @@  discard block
 block discarded – undo
531 527
 						'QSG_name'=>array('LIKE',"%$search_string%"),
532 528
 						'QSG_desc'=>array('LIKE',"%$search_string%"))
533 529
 					);
534
-			}else{
530
+			} else{
535 531
 				$query_params[0]=array(
536 532
 					'QST_display_text'=>array('LIKE',"%$search_string%")
537 533
 					);
@@ -587,7 +583,7 @@  discard block
 block discarded – undo
587 583
 		if ($count){
588 584
 			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
589 585
 			$results = $QST->count($where);
590
-		}else{
586
+		} else{
591 587
 			$results = $QST->get_all($query_params);
592 588
 		}
593 589
 		return $results;
Please login to merge, or discard this patch.
help_tabs/registration_form_reg_form_settings.help_tab.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,15 +3,15 @@
 block discarded – undo
3 3
 <?php _e('This page shows options for Email Validation, the EE "Bot Trap" and reCAPTCHA which can help prevent SPAM registrations on your site.', 'event_espresso'); ?>
4 4
 </p>
5 5
 <div id="email_validation_info">
6
-<p><strong><?php _e('Email Validation', 'event_espresso');?></strong></p>
6
+<p><strong><?php _e('Email Validation', 'event_espresso'); ?></strong></p>
7 7
 <p><?php _e("Validating an email address is extremely difficult to do correctly. Your server's configuration, as well as your own tolerances and needs, can affect the type of validation needed. We offer different types of validation so that you can control how strict your registration form responds to entered email addresses. If you are receiving too many bogus email addresses, then you can try the WordPress Default validation setting. If you find that the form validation is blocking a valid email address you can try the Basic setting, or if available, the International validation settings.", 'event_espresso'); ?>
8 8
 </p>
9
-<p><strong><?php _e('Validation Options:', 'event_espresso' );?></strong></p>
9
+<p><strong><?php _e('Validation Options:', 'event_espresso'); ?></strong></p>
10 10
 <ul>
11 11
 <li>
12 12
 	<?php _e('"Basic" - only checks that an email address follows the most basic structure guidelines ( ie: [email protected] ). Will work with the widest range of email addresses but will also allow the most garbage through.', 'event_espresso'); ?></li>
13 13
 <li>
14
-	<?php _e('"WordPress Default" - uses built in WordPress email validation, but does not support unicode characters (ie: international characters from non-latin based languages).','event_espresso'); ?></li>
14
+	<?php _e('"WordPress Default" - uses built in WordPress email validation, but does not support unicode characters (ie: international characters from non-latin based languages).', 'event_espresso'); ?></li>
15 15
 <li>
16 16
 	<?php _e('"International" - supports unicode characters but may not be supported by all server configurations. Try this first if you need to international language support, but drop back down to "Basic" if your server configuration conflicts.', 'event_espresso'); ?>
17 17
 </li>
Please login to merge, or discard this patch.
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -3,29 +3,29 @@  discard block
 block discarded – undo
3 3
 	exit('NO direct script access allowed');
4 4
 }
5 5
 /**
6
- * Event Espresso
7
- *
8
- * Event Registration and Management Plugin for Wordpress
9
- *
10
- * @package		Event Espresso
11
- * @author		Seth Shoultes
12
- * @copyright	(c)2009-2012 Event Espresso All Rights Reserved.
13
- * @license		http://eventespresso.com/support/terms-conditions/  ** see Plugin Licensing **
14
- * @link		http://www.eventespresso.com
15
- * @version		4.0
16
- *
17
- * ------------------------------------------------------------------------
18
- *
19
- * Extend_Registration_Form_Admin_Page
20
- *
21
- * This is the caffeinated version of the Registration Form admin pages.
22
- *
23
- * @package		Extend_Registration_Form_Admin_Page
24
- * @subpackage	caffeinated/admin/extend/Extend_Registration_Form_Admin_Page.core.php
25
- * @author		Darren Ethier
26
- *
27
- * ------------------------------------------------------------------------
28
- */
6
+	 * Event Espresso
7
+	 *
8
+	 * Event Registration and Management Plugin for Wordpress
9
+	 *
10
+	 * @package		Event Espresso
11
+	 * @author		Seth Shoultes
12
+	 * @copyright	(c)2009-2012 Event Espresso All Rights Reserved.
13
+	 * @license		http://eventespresso.com/support/terms-conditions/  ** see Plugin Licensing **
14
+	 * @link		http://www.eventespresso.com
15
+	 * @version		4.0
16
+	 *
17
+	 * ------------------------------------------------------------------------
18
+	 *
19
+	 * Extend_Registration_Form_Admin_Page
20
+	 *
21
+	 * This is the caffeinated version of the Registration Form admin pages.
22
+	 *
23
+	 * @package		Extend_Registration_Form_Admin_Page
24
+	 * @subpackage	caffeinated/admin/extend/Extend_Registration_Form_Admin_Page.core.php
25
+	 * @author		Darren Ethier
26
+	 *
27
+	 * ------------------------------------------------------------------------
28
+	 */
29 29
 class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page {
30 30
 
31 31
 
@@ -245,13 +245,13 @@  discard block
 block discarded – undo
245 245
 					'persistent' => FALSE
246 246
 					),
247 247
 				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
248
-                'help_tabs' => array(
248
+				'help_tabs' => array(
249 249
 					'registration_form_add_question_help_tab' => array(
250 250
 						'title' => __('Add Question', 'event_espresso'),
251 251
 						'filename' => 'registration_form_add_question'
252 252
 						),
253 253
 					),
254
-                'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'),
254
+				'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'),
255 255
 				'require_nonce' => FALSE
256 256
 				),
257 257
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 						'filename' => 'registration_form_add_question_group'
269 269
 						),
270 270
 					),
271
-                'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'),
271
+				'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'),
272 272
 				'require_nonce' => FALSE
273 273
 				),
274 274
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 						'filename' => 'registration_form_edit_question_group'
287 287
 						),
288 288
 					),
289
-                'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'),
289
+				'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'),
290 290
 				'require_nonce' => FALSE
291 291
 				),
292 292
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 						'filename' => 'registration_form_reg_form_settings'
306 306
 						),
307 307
 					),
308
-                'help_tour' => array( 'Registration_Form_Settings_Help_Tour'),
308
+				'help_tour' => array( 'Registration_Form_Settings_Help_Tour'),
309 309
 				'require_nonce' => FALSE
310 310
 				)
311 311
 
Please login to merge, or discard this patch.
Spacing   +181 added lines, -181 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
 /**
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 	 * 		@param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
37 37
 	 * 		@access public
38 38
 	 */
39
-	public function __construct( $routing = TRUE ) {
40
-		define( 'REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS );
41
-		define( 'REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS );
42
-		define( 'REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/' );
43
-		define( 'REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS );
44
-		define( 'REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/' );
45
-		parent::__construct( $routing );
39
+	public function __construct($routing = TRUE) {
40
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS);
41
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS);
42
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
43
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS);
44
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
45
+		parent::__construct($routing);
46 46
 	}
47 47
 
48 48
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 
53 53
 	protected function _extend_page_config() {
54 54
 		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
55
-		$qst_id = ! empty( $this->_req_data['QST_ID'] ) && ! is_array( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0;
56
-		$qsg_id = ! empty( $this->_req_data['QSG_ID'] ) && ! is_array( $this->_req_data['QSG_ID'] ) ? $this->_req_data['QSG_ID'] : 0;
55
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
56
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
57 57
 
58 58
 		$new_page_routes = array(
59 59
 			'question_groups' => array(
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 				'func' => '_trash_or_restore_questions',
87 87
 				'capability' => 'ee_delete_question',
88 88
 				'obj_id' => $qst_id,
89
-				'args' => array( 'trash' => FALSE ),
89
+				'args' => array('trash' => FALSE),
90 90
 				'noheader' => TRUE
91 91
 				),
92 92
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
 			'trash_question_group' => array(
147 147
 				'func' => '_trash_or_restore_question_groups',
148
-				'args' => array( 'trash' => TRUE ),
148
+				'args' => array('trash' => TRUE),
149 149
 				'capability' => 'ee_delete_question_group',
150 150
 				'obj_id' => $qsg_id,
151 151
 				'noheader' => TRUE
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
 			'restore_question_group' => array(
155 155
 				'func' => '_trash_or_restore_question_groups',
156
-				'args' => array( 'trash' => FALSE ),
156
+				'args' => array('trash' => FALSE),
157 157
 				'capability' => 'ee_delete_question_group',
158 158
 				'obj_id' => $qsg_id,
159 159
 				'noheader' => TRUE
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 			'update_question_group' => array(
170 170
 				'func' => '_insert_or_update_question_group',
171
-				'args' => array('new_question_group' => FALSE ),
171
+				'args' => array('new_question_group' => FALSE),
172 172
 				'capability' => 'ee_edit_question_group',
173 173
 				'obj_id' => $qsg_id,
174 174
 				'noheader' => TRUE,
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 					'noheader' => TRUE
207 207
 				),
208 208
 			);
209
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
209
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
210 210
 
211 211
 		$new_page_config = array(
212 212
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 						'filename' => 'registration_form_question_groups_views_bulk_actions_search'
231 231
 						),
232 232
 					),
233
-				'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'),
233
+				'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'),
234 234
 				'metaboxes' => $this->_default_espresso_metaboxes,
235 235
 				'require_nonce' => FALSE,
236 236
 				'qtips' => array(
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 					'order' => 5,
245 245
 					'persistent' => FALSE
246 246
 					),
247
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
247
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
248 248
                 'help_tabs' => array(
249 249
 					'registration_form_add_question_help_tab' => array(
250 250
 						'title' => __('Add Question', 'event_espresso'),
251 251
 						'filename' => 'registration_form_add_question'
252 252
 						),
253 253
 					),
254
-                'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'),
254
+                'help_tour' => array('Registration_Form_Add_Question_Help_Tour'),
255 255
 				'require_nonce' => FALSE
256 256
 				),
257 257
 
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
 					'order' => 5,
262 262
 					'persistent' => FALSE
263 263
 					),
264
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
264
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
265 265
 				'help_tabs' => array(
266 266
 					'registration_form_add_question_group_help_tab' => array(
267 267
 						'title' => __('Add Question Group', 'event_espresso'),
268 268
 						'filename' => 'registration_form_add_question_group'
269 269
 						),
270 270
 					),
271
-                'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'),
271
+                'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'),
272 272
 				'require_nonce' => FALSE
273 273
 				),
274 274
 
@@ -277,16 +277,16 @@  discard block
 block discarded – undo
277 277
 					'label' => __('Edit Question Group', 'event_espresso'),
278 278
 					'order' => 5,
279 279
 					'persistent' => FALSE,
280
-					'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id'] ), $this->_current_page_view_url )  : $this->_admin_base_url
280
+					'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), $this->_current_page_view_url) : $this->_admin_base_url
281 281
 					),
282
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
282
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
283 283
 				'help_tabs' => array(
284 284
 					'registration_form_edit_question_group_help_tab' => array(
285 285
 						'title' => __('Edit Question Group', 'event_espresso'),
286 286
 						'filename' => 'registration_form_edit_question_group'
287 287
 						),
288 288
 					),
289
-                'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'),
289
+                'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'),
290 290
 				'require_nonce' => FALSE
291 291
 				),
292 292
 
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
 				'labels' => array(
299 299
 					'publishbox' => __('Update Settings', 'event_espresso')
300 300
 					),
301
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
301
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
302 302
 				'help_tabs' => array(
303 303
 					'registration_form_reg_form_settings_help_tab' => array(
304 304
 						'title' => __('Registration Form Settings', 'event_espresso'),
305 305
 						'filename' => 'registration_form_reg_form_settings'
306 306
 						),
307 307
 					),
308
-                'help_tour' => array( 'Registration_Form_Settings_Help_Tour'),
308
+                'help_tour' => array('Registration_Form_Settings_Help_Tour'),
309 309
 				'require_nonce' => FALSE
310 310
 				)
311 311
 
312 312
 			);
313
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
313
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
314 314
 
315 315
 		//change the list table we're going to use so it's the NEW list table!
316 316
 		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			'edit_question_group' => __('Edit Question Group', 'event_espresso'),
325 325
 			'delete_question_group' => __('Delete Question Group', 'event_espresso'),
326 326
 			);
327
-		$this->_labels['buttons'] = array_merge( $this->_labels['buttons'], $new_labels );
327
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
328 328
 
329 329
 	}
330 330
 
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
 
334 334
 
335 335
 	protected function _ajax_hooks() {
336
-		add_action('wp_ajax_espresso_update_question_group_order', array( $this, 'update_question_group_order' ));
336
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
337 337
 	}
338 338
 
339 339
 
340 340
 
341 341
 
342 342
 	public function load_scripts_styles_question_groups() {
343
-		wp_enqueue_script( 'espresso_ajax_table_sorting' );
343
+		wp_enqueue_script('espresso_ajax_table_sorting');
344 344
 	}
345 345
 
346 346
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @return void
362 362
 	 */
363 363
 	public function load_sortable_question_script() {
364
-		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
364
+		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
365 365
 		wp_enqueue_script('ee-question-sortable');
366 366
 	}
367 367
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 				)
381 381
 		);
382 382
 
383
-		if ( EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) {
383
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) {
384 384
 			$this->_views['trash'] = array(
385 385
 				'slug' => 'trash',
386 386
 				'label' => __('Trash', 'event_espresso'),
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 				)
411 411
 		);
412 412
 
413
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups' ) ) {
413
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups')) {
414 414
 			$this->_views['trash'] = array(
415 415
 				'slug' => 'trash',
416 416
 				'label' => __('Trash', 'event_espresso'),
@@ -446,24 +446,24 @@  discard block
 block discarded – undo
446 446
 
447 447
 
448 448
 
449
-	protected function _delete_question(){
450
-		$success = $this->_delete_items( $this->_question_model );
449
+	protected function _delete_question() {
450
+		$success = $this->_delete_items($this->_question_model);
451 451
 		$this->_redirect_after_action(
452 452
 			$success,
453
-			$this->_question_model->item_name( $success ),
453
+			$this->_question_model->item_name($success),
454 454
 			'deleted',
455
-			array( 'action' => 'default', 'status' => 'all' )
455
+			array('action' => 'default', 'status' => 'all')
456 456
 		);
457 457
 	}
458 458
 
459 459
 
460 460
 	protected function _delete_questions() {
461
-		$success = $this->_delete_items( $this->_question_model );
461
+		$success = $this->_delete_items($this->_question_model);
462 462
 		$this->_redirect_after_action(
463 463
 			$success,
464
-			$this->_question_model->item_name( $success ),
464
+			$this->_question_model->item_name($success),
465 465
 			'deleted permanently',
466
-			array( 'action' => 'default', 'status' => 'trash' )
466
+			array('action' => 'default', 'status' => 'trash')
467 467
 		);
468 468
 	}
469 469
 
@@ -474,26 +474,26 @@  discard block
 block discarded – undo
474 474
  * @param EEM_Soft_Delete_Base $model
475 475
  * @return int number of items deleted permanently
476 476
  */
477
-	private function _delete_items(EEM_Soft_Delete_Base $model){
477
+	private function _delete_items(EEM_Soft_Delete_Base $model) {
478 478
 		$success = 0;
479
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
480
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
479
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481 481
 			// if array has more than one element than success message should be plural
482
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
482
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483 483
 			// cycle thru bulk action checkboxes
484
-			while (list( $ID, $value ) = each($this->_req_data['checkbox'])) {
485
-				if ( ! $this->_delete_item( $ID, $model ) ) {
484
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
+				if ( ! $this->_delete_item($ID, $model)) {
486 486
 					$success = 0;
487 487
 				}
488 488
 			}
489 489
 
490
-		}elseif( !empty($this->_req_data['QSG_ID'])){
491
-			$success = $this->_delete_item( $this->_req_data['QSG_ID'], $model );
490
+		}elseif ( ! empty($this->_req_data['QSG_ID'])) {
491
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492 492
 
493
-		}elseif( !empty($this->_req_data['QST_ID'])){
494
-			$success = $this->_delete_item( $this->_req_data['QST_ID'], $model );
495
-		}else{
496
-			EE_Error::add_error( sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
493
+		}elseif ( ! empty($this->_req_data['QST_ID'])) {
494
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495
+		} else {
496
+			EE_Error::add_error(sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
497 497
 		}
498 498
 		return $success;
499 499
 	}
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 	 * @param EEM_Soft_Delete_Base $model
505 505
 	 * @return boolean
506 506
 	 */
507
-	protected function _delete_item( $id, $model ) {
508
-		if( $model instanceof EEM_Question ) {
509
-			EEM_Question_Option::instance()->delete_permanently( array( array( 'QST_ID' => absint( $id ) ) ) );
507
+	protected function _delete_item($id, $model) {
508
+		if ($model instanceof EEM_Question) {
509
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
510 510
 		}
511
-		return $model->delete_permanently_by_ID( absint( $id ) );
511
+		return $model->delete_permanently_by_ID(absint($id));
512 512
 	}
513 513
 
514 514
 
@@ -520,31 +520,31 @@  discard block
 block discarded – undo
520 520
 
521 521
 
522 522
 
523
-	protected function _edit_question_group( $type = 'add' ) {
524
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
525
-		$ID=isset( $this->_req_data['QSG_ID'] ) && ! empty( $this->_req_data['QSG_ID'] ) ? absint( $this->_req_data['QSG_ID'] ) : FALSE;
526
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
523
+	protected function _edit_question_group($type = 'add') {
524
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
525
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : FALSE;
526
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
527 527
 		// add ID to title if editing
528
-		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
529
-		if($ID){
528
+		$this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
529
+		if ($ID) {
530 530
 			/** @var EE_Question_Group $questionGroup */
531
-			$questionGroup=$this->_question_group_model->get_one_by_ID( $ID);
532
-			$additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID));
531
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
532
+			$additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID));
533 533
 			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
534
-		}else{
534
+		} else {
535 535
 			/** @var EE_Question_Group $questionGroup */
536 536
 			$questionGroup = EEM_Question_Group::instance()->create_default_object();
537 537
 			$questionGroup->set_order_to_latest();
538 538
 			$this->_set_add_edit_form_tags('insert_question_group');
539 539
 		}
540 540
 		$this->_template_args['values'] = $this->_yes_no_values;
541
-		$this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group();
542
-		$this->_template_args['QSG_ID']=$ID ? $ID : TRUE;
543
-		$this->_template_args['question_group']=$questionGroup;
541
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
542
+		$this->_template_args['QSG_ID'] = $ID ? $ID : TRUE;
543
+		$this->_template_args['question_group'] = $questionGroup;
544 544
 
545
-		$redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url );
546
-		$this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL  );
547
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', $this->_template_args, TRUE );
545
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
546
+		$this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL);
547
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', $this->_template_args, TRUE);
548 548
 
549 549
 		// the details template wrapper
550 550
 		$this->display_admin_page_with_sidebar();
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
 	protected function _delete_question_groups() {
557 557
 		$success = $this->_delete_items($this->_question_group_model);
558
-		$this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' ));
558
+		$this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash'));
559 559
 	}
560 560
 
561 561
 
@@ -563,71 +563,71 @@  discard block
 block discarded – undo
563 563
 	/**
564 564
 	 * @param bool $new_question_group
565 565
 	 */
566
-	protected function _insert_or_update_question_group( $new_question_group = TRUE) {
567
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
568
-		$set_column_values=$this->_set_column_values_for($this->_question_group_model);
569
-		if ( $new_question_group ){
566
+	protected function _insert_or_update_question_group($new_question_group = TRUE) {
567
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
568
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
569
+		if ($new_question_group) {
570 570
 			$QSG_ID = $this->_question_group_model->insert($set_column_values);
571 571
 			$success = $QSG_ID ? 1 : 0;
572 572
 		} else {
573 573
 			$QSG_ID = absint($this->_req_data['QSG_ID']);
574
-			unset( $set_column_values[ 'QSG_ID' ] );
575
-			$success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID )));
574
+			unset($set_column_values['QSG_ID']);
575
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
576 576
 		}
577
-		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone );
577
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
578 578
 		// update the existing related questions
579 579
 		// BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
580
-		if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) {
580
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
581 581
 			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
582
-			EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID ))));
582
+			EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID))));
583 583
 		}
584 584
 		/** @type EE_Question_Group $question_group */
585
-		$question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID );
585
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
586 586
 		$questions = $question_group->questions();
587 587
 		// make sure system phone question is added to list of questions for this group
588
-		if ( ! isset( $questions[$phone_question_id ] )) {
589
-			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id );
588
+		if ( ! isset($questions[$phone_question_id])) {
589
+			$questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
590 590
 		}
591 591
 
592
-		foreach( $questions as $question_ID => $question ){
592
+		foreach ($questions as $question_ID => $question) {
593 593
 			// first we always check for order.
594
-			if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){
594
+			if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
595 595
 				//update question order
596
-				$question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] );
596
+				$question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
597 597
 			}
598 598
 
599 599
 			// then we always check if adding or removing.
600
-			if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) {
601
-				$question_group->add_question( $question_ID );
600
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
601
+				$question_group->add_question($question_ID);
602 602
 			} else {
603 603
 				// not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
604 604
 				if (
605 605
 					in_array(
606 606
 						$question->system_ID(),
607
-						EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() )
607
+						EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
608 608
 					)
609 609
 				) {
610 610
 					continue;
611 611
 				} else {
612
-					$question_group->remove_question( $question_ID );
612
+					$question_group->remove_question($question_ID);
613 613
 				}
614 614
 			}
615 615
 		}
616 616
 		// save new related questions
617
-		if ( isset( $this->_req_data['questions'] )) {
618
-			foreach( $this->_req_data['questions'] as $QST_ID ){
619
-				$question_group->add_question( $QST_ID );
620
-				if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) {
621
-					$question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] );
617
+		if (isset($this->_req_data['questions'])) {
618
+			foreach ($this->_req_data['questions'] as $QST_ID) {
619
+				$question_group->add_question($QST_ID);
620
+				if (isset($this->_req_data['question_orders'][$QST_ID])) {
621
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
622 622
 				}
623 623
 			}
624 624
 		}
625 625
 
626
-		if ( $success !== FALSE ) {
627
-			$msg = $new_question_group ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_group_model->item_name() );
628
-			EE_Error::add_success( $msg );
626
+		if ($success !== FALSE) {
627
+			$msg = $new_question_group ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_group_model->item_name());
628
+			EE_Error::add_success($msg);
629 629
 		}
630
-		$this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE);
630
+		$this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE);
631 631
 
632 632
 	}
633 633
 
@@ -635,20 +635,20 @@  discard block
 block discarded – undo
635 635
 	 * duplicates a question and all its question options and redirects to the new question.
636 636
 	 */
637 637
 	public function _duplicate_question() {
638
-		$question_ID = (int)$this->_req_data[ 'QST_ID' ];
639
-		$question = EEM_Question::instance()->get_one_by_ID( $question_ID );
640
-		if( $question instanceof EE_Question ) {
638
+		$question_ID = (int) $this->_req_data['QST_ID'];
639
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
640
+		if ($question instanceof EE_Question) {
641 641
 			$new_question = $question->duplicate();
642
-			if( $new_question instanceof EE_Question ) {
643
-				$this->_redirect_after_action( true, __( 'Question', 'event_espresso' ), __( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE);
642
+			if ($new_question instanceof EE_Question) {
643
+				$this->_redirect_after_action(true, __('Question', 'event_espresso'), __('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE);
644 644
 			} else {
645 645
 				global $wpdb;
646
-				EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %1$d because: %2$s', 'event_espresso' ), $question_ID, $wpdb->last_error ), __FILE__, __FUNCTION__, __LINE__ );
647
-			$this->_redirect_after_action(false, '', '', array('action'=>'default'), false );
646
+				EE_Error::add_error(sprintf(__('Could not duplicate question with ID %1$d because: %2$s', 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
647
+			$this->_redirect_after_action(false, '', '', array('action'=>'default'), false);
648 648
 			}
649 649
 		} else {
650
-			EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ );
651
-			$this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false );
650
+			EE_Error::add_error(sprintf(__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
651
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
652 652
 		}
653 653
 	}
654 654
 
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
 	/**
658 658
 	 * @param bool $trash
659 659
 	 */
660
-	protected function _trash_or_restore_question_groups( $trash = TRUE) {
661
-		$this->_trash_or_restore_items( $this->_question_group_model, $trash );
660
+	protected function _trash_or_restore_question_groups($trash = TRUE) {
661
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
662 662
 	}
663 663
 
664 664
 
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 	/**
667 667
 	 *_trash_question
668 668
 	 */
669
-	protected function _trash_question(){
670
-		$success=$this->_question_model->delete_by_ID( (int)$this->_req_data['QST_ID'] );
671
-		$query_args=array('action'=>'default','status'=>'all');
669
+	protected function _trash_question() {
670
+		$success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
671
+		$query_args = array('action'=>'default', 'status'=>'all');
672 672
 		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
673 673
 	}
674 674
 
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
 	/**
678 678
 	 * @param bool $trash
679 679
 	 */
680
-	protected function _trash_or_restore_questions( $trash=TRUE){
681
-		$this->_trash_or_restore_items( $this->_question_model, $trash );
680
+	protected function _trash_or_restore_questions($trash = TRUE) {
681
+		$this->_trash_or_restore_items($this->_question_model, $trash);
682 682
 	}
683 683
 
684 684
 
@@ -690,21 +690,21 @@  discard block
 block discarded – undo
690 690
 *@param EEM_Soft_Delete_Base $model
691 691
 	 * @param boolean $trash whether to trash or restore
692 692
 	 */
693
-	private function _trash_or_restore_items( EEM_Soft_Delete_Base $model, $trash = TRUE ) {
693
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = TRUE) {
694 694
 
695
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
695
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
696 696
 
697 697
 		$success = 1;
698 698
 		//Checkboxes
699 699
 		//echo "trash $trash";
700 700
 		//var_dump($this->_req_data['checkbox']);die;
701
-		if ( isset( $this->_req_data['checkbox'] )) {
702
-			if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) {
701
+		if (isset($this->_req_data['checkbox'])) {
702
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
703 703
 				// if array has more than one element than success message should be plural
704
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
704
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
705 705
 				// cycle thru bulk action checkboxes
706
-				while (list( $ID, $value ) = each($this->_req_data['checkbox'])) {
707
-					if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) {
706
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
707
+					if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
708 708
 						$success = 0;
709 709
 					}
710 710
 				}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			} else {
713 713
 				// grab single id and delete
714 714
 				$ID = absint($this->_req_data['checkbox']);
715
-				if ( ! $model->delete_or_restore_by_ID($trash,$ID)) {
715
+				if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
716 716
 					$success = 0;
717 717
 				}
718 718
 			}
@@ -720,25 +720,25 @@  discard block
 block discarded – undo
720 720
 		} else {
721 721
 			// delete via trash link
722 722
 			// grab single id and delete
723
-			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
724
-			if ( ! $model->delete_or_restore_by_ID($trash,$ID)) {
723
+			$ID = absint($this->_req_data[$model->primary_key_name()]);
724
+			if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
725 725
 				$success = 0;
726 726
 			}
727 727
 
728 728
 		}
729 729
 
730 730
 
731
-		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
731
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) );
732 732
 		//echo "action :$action";
733 733
 		//$action = 'questions' ? 'default' : $action;
734
-		if($trash){
734
+		if ($trash) {
735 735
 			$action_desc = 'trashed';
736 736
 			$status = 'trash';
737
-		}else{
737
+		} else {
738 738
 			$action_desc = 'restored';
739 739
 			$status = 'all';
740 740
 		}
741
-		$this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) );
741
+		$this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status));
742 742
 	}
743 743
 
744 744
 
@@ -749,16 +749,16 @@  discard block
 block discarded – undo
749 749
 	 * @param bool|false $count
750 750
 	 * @return \EE_Soft_Delete_Base_Class[]|int
751 751
 	 */
752
-	public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) {
752
+	public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) {
753 753
 		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
754 754
 
755
-		if( $count ){
755
+		if ($count) {
756 756
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
757
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
758
-			$results=$this->_question_model->count_deleted($where);
759
-		}else{
757
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
758
+			$results = $this->_question_model->count_deleted($where);
759
+		} else {
760 760
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
761
-			$results=$this->_question_model->get_all_deleted($query_params);
761
+			$results = $this->_question_model->get_all_deleted($query_params);
762 762
 		}
763 763
 		return $results;
764 764
 	}
@@ -771,13 +771,13 @@  discard block
 block discarded – undo
771 771
 	 * @param bool|false $count
772 772
 	 * @return \EE_Soft_Delete_Base_Class[]
773 773
 	 */
774
-	public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
775
-		$questionGroupModel=EEM_Question_Group::instance();
776
-		$query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page);
777
-		if ($count){
778
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
774
+	public function get_question_groups($per_page, $current_page = 1, $count = FALSE) {
775
+		$questionGroupModel = EEM_Question_Group::instance();
776
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
777
+		if ($count) {
778
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
779 779
 			$results = $questionGroupModel->count($where);
780
-		}else{
780
+		} else {
781 781
 			$results = $questionGroupModel->get_all($query_params);
782 782
 		}
783 783
 		return $results;
@@ -791,14 +791,14 @@  discard block
 block discarded – undo
791 791
 	 * @param bool $count
792 792
 	 * @return \EE_Soft_Delete_Base_Class[]|int
793 793
 	 */
794
-	public function get_trashed_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
795
-		$questionGroupModel=EEM_Question_Group::instance();
796
-		$query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page);
797
-		if($count){
798
-			$where = isset( $query_params[0] ) ? array($query_params[0]) : array();
794
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) {
795
+		$questionGroupModel = EEM_Question_Group::instance();
796
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
797
+		if ($count) {
798
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
799 799
 			$query_params['limit'] = NULL;
800 800
 			$results = $questionGroupModel->count_deleted($where);
801
-		}else{
801
+		} else {
802 802
 			$results = $questionGroupModel->get_all_deleted($query_params);
803 803
 		}
804 804
 		return $results;
@@ -811,32 +811,32 @@  discard block
 block discarded – undo
811 811
 	 */
812 812
 	public function update_question_group_order() {
813 813
 
814
-		$success = __( 'Question group order was updated successfully.', 'event_espresso' );
814
+		$success = __('Question group order was updated successfully.', 'event_espresso');
815 815
 
816 816
 		// grab our row IDs
817
-		$row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] )
818
-			? explode( ',', rtrim( $this->_req_data['row_ids'], ',' ))
817
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
818
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
819 819
 			: array();
820 820
 
821
-		$perpage = !empty( $this->_req_data['perpage'] )
821
+		$perpage = ! empty($this->_req_data['perpage'])
822 822
 			? (int) $this->_req_data['perpage']
823 823
 			: NULL;
824
-		$curpage = !empty( $this->_req_data['curpage'] )
824
+		$curpage = ! empty($this->_req_data['curpage'])
825 825
 			? (int) $this->_req_data['curpage']
826 826
 			: NULL;
827 827
 
828
-		if ( ! empty( $row_ids ) ) {
828
+		if ( ! empty($row_ids)) {
829 829
 			//figure out where we start the row_id count at for the current page.
830
-			$qsgcount = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage;
830
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
831 831
 
832
-			$row_count = count( $row_ids );
833
-			for( $i = 0; $i < $row_count; $i++ ) {
832
+			$row_count = count($row_ids);
833
+			for ($i = 0; $i < $row_count; $i++) {
834 834
 				//Update the questions when re-ordering
835 835
 				$updated = EEM_Question_Group::instance()->update(
836
-					array( 'QSG_order' => $qsgcount ),
837
-					array( array( 'QSG_ID' => $row_ids[ $i ] ) )
836
+					array('QSG_order' => $qsgcount),
837
+					array(array('QSG_ID' => $row_ids[$i]))
838 838
 				);
839
-				if ( $updated === false ) {
839
+				if ($updated === false) {
840 840
 					$success = false;
841 841
 				}
842 842
 				$qsgcount++;
@@ -846,10 +846,10 @@  discard block
 block discarded – undo
846 846
 		}
847 847
 
848 848
 		$errors = ! $success
849
-			? __( 'An error occurred. The question group order was not updated.', 'event_espresso' )
849
+			? __('An error occurred. The question group order was not updated.', 'event_espresso')
850 850
 			: false;
851 851
 
852
-		echo json_encode( array( 'return_data' => false, 'success' => $success, 'errors' => $errors ));
852
+		echo json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
853 853
 		die();
854 854
 
855 855
 	}
@@ -868,17 +868,17 @@  discard block
 block discarded – undo
868 868
 		$this->_template_args['values'] = $this->_yes_no_values;
869 869
 		add_action(
870 870
 			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
871
-			array( $this, 'email_validation_settings_form' ),
871
+			array($this, 'email_validation_settings_form'),
872 872
 			2
873 873
 		);
874
-		$this->_template_args = (array)apply_filters(
874
+		$this->_template_args = (array) apply_filters(
875 875
 			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
876 876
 			$this->_template_args
877 877
 		);
878
-		$this->_set_add_edit_form_tags( 'update_reg_form_settings' );
879
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
878
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
879
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
880 880
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
881
-			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
881
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php',
882 882
 			$this->_template_args,
883 883
 			TRUE
884 884
 		);
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 			EE_Registry::instance()->CFG,
900 900
 			__FILE__, __FUNCTION__, __LINE__
901 901
 		);
902
-		$this->_redirect_after_action( $success, __('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) );
902
+		$this->_redirect_after_action($success, __('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings'));
903 903
 	}
904 904
 
905 905
 
@@ -930,19 +930,19 @@  discard block
 block discarded – undo
930 930
 				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
931 931
 				'subsections'     => array(
932 932
 					'email_validation_hdr'           => new EE_Form_Section_HTML(
933
-						EEH_HTML::h2( __( 'Email Validation Settings', 'event_espresso' ) )
933
+						EEH_HTML::h2(__('Email Validation Settings', 'event_espresso'))
934 934
 					),
935 935
 					'email_validation_level' => new EE_Select_Input(
936 936
 						array(
937
-							'basic'      => __( 'Basic', 'event_espresso' ),
938
-							'wp_default' => __( 'WordPress Default', 'event_espresso' ),
939
-							'i18n'       => __( 'International', 'event_espresso' ),
940
-							'i18n_dns'   => __( 'International + DNS Check', 'event_espresso' ),
937
+							'basic'      => __('Basic', 'event_espresso'),
938
+							'wp_default' => __('WordPress Default', 'event_espresso'),
939
+							'i18n'       => __('International', 'event_espresso'),
940
+							'i18n_dns'   => __('International + DNS Check', 'event_espresso'),
941 941
 						),
942 942
 						array(
943
-							'html_label_text' => __( 'Email Validation Level', 'event_espresso' ),
944
-							'html_help_text'  => __( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) and addition MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'),
945
-							'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level )
943
+							'html_label_text' => __('Email Validation Level', 'event_espresso'),
944
+							'html_help_text'  => __('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) and addition MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'),
945
+							'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level)
946 946
 								? EE_Registry::instance()->CFG->registration->email_validation_level
947 947
 								: 'wp_default',
948 948
 							'required'        => false
@@ -961,18 +961,18 @@  discard block
 block discarded – undo
961 961
 	 * @param \EE_Registration_Config $EE_Registration_Config
962 962
 	 * @return \EE_Registration_Config
963 963
 	 */
964
-	public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) {
964
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) {
965 965
 		try {
966 966
 			$email_validation_settings_form = $this->_email_validation_settings_form();
967 967
 			// if not displaying a form, then check for form submission
968
-			if ( $email_validation_settings_form->was_submitted() ) {
968
+			if ($email_validation_settings_form->was_submitted()) {
969 969
 				// capture form data
970 970
 				$email_validation_settings_form->receive_form_submission();
971 971
 				// validate form data
972
-				if ( $email_validation_settings_form->is_valid() ) {
972
+				if ($email_validation_settings_form->is_valid()) {
973 973
 					// grab validated data from form
974 974
 					$valid_data = $email_validation_settings_form->valid_data();
975
-					if ( isset( $valid_data['email_validation_level'] ) ) {
975
+					if (isset($valid_data['email_validation_level'])) {
976 976
 						$EE_Registration_Config->email_validation_level = $valid_data['email_validation_level'];
977 977
 					} else {
978 978
 						EE_Error::add_error(
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 						);
987 987
 					}
988 988
 				} else {
989
-					if ( $email_validation_settings_form->submission_error_message() !== '' ) {
989
+					if ($email_validation_settings_form->submission_error_message() !== '') {
990 990
 						EE_Error::add_error(
991 991
 							$email_validation_settings_form->submission_error_message(),
992 992
 							__FILE__,
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 					}
997 997
 				}
998 998
 			}
999
-		} catch ( EE_Error $e ) {
999
+		} catch (EE_Error $e) {
1000 1000
 			$e->get_error();
1001 1001
 		}
1002 1002
 		return $EE_Registration_Config;
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -487,12 +487,12 @@  discard block
 block discarded – undo
487 487
 				}
488 488
 			}
489 489
 
490
-		}elseif( !empty($this->_req_data['QSG_ID'])){
490
+		} elseif( !empty($this->_req_data['QSG_ID'])){
491 491
 			$success = $this->_delete_item( $this->_req_data['QSG_ID'], $model );
492 492
 
493
-		}elseif( !empty($this->_req_data['QST_ID'])){
493
+		} elseif( !empty($this->_req_data['QST_ID'])){
494 494
 			$success = $this->_delete_item( $this->_req_data['QST_ID'], $model );
495
-		}else{
495
+		} else{
496 496
 			EE_Error::add_error( sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
497 497
 		}
498 498
 		return $success;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 			$questionGroup=$this->_question_group_model->get_one_by_ID( $ID);
532 532
 			$additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID));
533 533
 			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
534
-		}else{
534
+		} else{
535 535
 			/** @var EE_Question_Group $questionGroup */
536 536
 			$questionGroup = EEM_Question_Group::instance()->create_default_object();
537 537
 			$questionGroup->set_order_to_latest();
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 		if($trash){
735 735
 			$action_desc = 'trashed';
736 736
 			$status = 'trash';
737
-		}else{
737
+		} else{
738 738
 			$action_desc = 'restored';
739 739
 			$status = 'all';
740 740
 		}
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
757 757
 			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
758 758
 			$results=$this->_question_model->count_deleted($where);
759
-		}else{
759
+		} else{
760 760
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
761 761
 			$results=$this->_question_model->get_all_deleted($query_params);
762 762
 		}
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 		if ($count){
778 778
 			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
779 779
 			$results = $questionGroupModel->count($where);
780
-		}else{
780
+		} else{
781 781
 			$results = $questionGroupModel->get_all($query_params);
782 782
 		}
783 783
 		return $results;
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 			$where = isset( $query_params[0] ) ? array($query_params[0]) : array();
799 799
 			$query_params['limit'] = NULL;
800 800
 			$results = $questionGroupModel->count_deleted($where);
801
-		}else{
801
+		} else{
802 802
 			$results = $questionGroupModel->get_all_deleted($query_params);
803 803
 		}
804 804
 		return $results;
Please login to merge, or discard this patch.
core/db_models/EEM_Question.model.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
 	exit('No direct script access allowed');
3 3
 }
4
-require_once( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
5
-require_once( EE_CLASSES . 'EE_Question.class.php' );
4
+require_once(EE_MODELS.'EEM_Soft_Delete_Base.model.php');
5
+require_once(EE_CLASSES.'EE_Question.class.php');
6 6
 
7 7
 
8 8
 
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * @param null $timezone
76 76
 	 */
77
-	protected function __construct( $timezone = NULL ) {
78
-		$this->singular_item = __('Question','event_espresso');
79
-		$this->plural_item = __('Questions','event_espresso');
80
-		$this->_allowed_question_types=apply_filters(
77
+	protected function __construct($timezone = NULL) {
78
+		$this->singular_item = __('Question', 'event_espresso');
79
+		$this->plural_item = __('Questions', 'event_espresso');
80
+		$this->_allowed_question_types = apply_filters(
81 81
 			'FHEE__EEM_Question__construct__allowed_question_types',
82 82
 			array(
83
-				EEM_Question::QST_type_text =>__('Text','event_espresso'),
84
-				EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'),
85
-				EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'),
86
-				EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'),
87
-				EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'),
88
-				EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'),
89
-				EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'),
90
-				EEM_Question::QST_type_date =>__('Date Picker','event_espresso'),
91
-				EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ),
83
+				EEM_Question::QST_type_text =>__('Text', 'event_espresso'),
84
+				EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'),
85
+				EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'),
86
+				EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'),
87
+				EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'),
88
+				EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'),
89
+				EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'),
90
+				EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'),
91
+				EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
92 92
 			)
93 93
 		);
94
-		$this->_question_type_categories = (array)apply_filters(
94
+		$this->_question_type_categories = (array) apply_filters(
95 95
 				'FHEE__EEM_Question__construct__question_type_categories',
96 96
 				array(
97 97
 				'text' => array(
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 
109 109
 		$this->_tables = array(
110
-			'Question'=>new EE_Primary_Table('esp_question','QST_ID')
110
+			'Question'=>new EE_Primary_Table('esp_question', 'QST_ID')
111 111
 		);
112 112
 		$this->_fields = array(
113 113
 			'Question'=>array(
114
-				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')),
115
-				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''),
116
-				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''),
117
-				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ),
118
-				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types),
119
-				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false),
120
-				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''),
121
-				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0),
122
-				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false),
123
-				'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso'	), false, EE_INF ),
124
-				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ),
125
-				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false)
114
+				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
115
+				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
116
+				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
117
+				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), TRUE, NULL),
118
+				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
119
+				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
120
+				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
121
+				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
122
+				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
123
+				'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF),
124
+				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
125
+				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
126 126
 			)
127 127
 		);
128 128
 		$this->_model_relations = array(
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 			'Question_Group_Question'=>new EE_Has_Many_Relation()
135 135
 		);
136 136
 		//this model is generally available for reading
137
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
138
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system');
139
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system');
140
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system');
141
-		parent::__construct( $timezone );
137
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
138
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system');
139
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system');
140
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system');
141
+		parent::__construct($timezone);
142 142
 	}
143 143
 
144 144
 	/**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * but they can be extended
147 147
 	 * @return string[]
148 148
 	 */
149
-	public function allowed_question_types(){
149
+	public function allowed_question_types() {
150 150
 		return $this->_allowed_question_types;
151 151
 	}
152 152
 	/**
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
 	 * @param string $question_type one of EEM_Question::allowed_question_types(
155 155
 	 * @return string[] like EEM_Question::allowed_question_types()
156 156
 	 */
157
-	public function question_types_in_same_category( $question_type ) {
158
-		$question_types = array( $question_type );
159
-		foreach( $this->_question_type_categories as $category => $question_types_in_category ) {
160
-			if( in_array( $question_type, $question_types_in_category ) ) {
157
+	public function question_types_in_same_category($question_type) {
158
+		$question_types = array($question_type);
159
+		foreach ($this->_question_type_categories as $category => $question_types_in_category) {
160
+			if (in_array($question_type, $question_types_in_category)) {
161 161
 				$question_types = $question_types_in_category;
162 162
 				break;
163 163
 			}
164 164
 		}
165 165
 
166
-		return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) );
166
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
167 167
 	}
168 168
 
169 169
 	/**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param string $category one of the top-level keys of EEM_Question::question_type_categories()
173 173
 	 * @return boolean
174 174
 	 */
175
-	public function question_type_is_in_category( $question_type, $category ) {
176
-		if( ! isset( $this->_question_type_categories[ $category ] ) ) {
175
+	public function question_type_is_in_category($question_type, $category) {
176
+		if ( ! isset($this->_question_type_categories[$category])) {
177 177
 			return false;
178 178
 		}
179
-		return in_array( $question_type, $this->_question_type_categories[ $category ] );
179
+		return in_array($question_type, $this->_question_type_categories[$category]);
180 180
 	}
181 181
 
182 182
 	/**
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 * @param string $system_question_group_id QSG_system
194 194
 	 * @return array of system question names (QST_system)
195 195
 	 */
196
-	public function allowed_system_questions_in_system_question_group( $system_question_group_id ) {
196
+	public function allowed_system_questions_in_system_question_group($system_question_group_id) {
197 197
 		$question_system_ids = array();
198
-		switch( $system_question_group_id ) {
198
+		switch ($system_question_group_id) {
199 199
 			case EEM_Question_Group::system_personal:
200 200
 				$question_system_ids = array(
201 201
 					EEM_Attendee::system_question_fname,
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 				);
217 217
 				break;
218 218
 		}
219
-		return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id );
219
+		return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
220 220
 	}
221 221
 
222 222
 	/**
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	 * @param string $system_question_group_id QSG_system
226 226
 	 * @return array of system question names (QST_system)
227 227
 	 */
228
-	public function required_system_questions_in_system_question_group( $system_question_group_id ) {
228
+	public function required_system_questions_in_system_question_group($system_question_group_id) {
229 229
 		$question_system_ids = null;
230
-		switch( $system_question_group_id ) {
230
+		switch ($system_question_group_id) {
231 231
 			case EEM_Question_Group::system_personal:
232
-				$question_system_ids =  array(
232
+				$question_system_ids = array(
233 233
 					EEM_Attendee::system_question_fname,
234 234
 					EEM_Attendee::system_question_email,
235 235
 				);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			default:
238 238
 				$question_system_ids = array();
239 239
 		}
240
-		return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id );
240
+		return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
241 241
 	}
242 242
 
243 243
 
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param $QST_system
249 249
 	 * @return int of QST_ID for the question that corresponds to that QST_system
250 250
 	 */
251
-	public function get_Question_ID_from_system_string( $QST_system ){
252
-		 return $this->get_var( array( array( 'QST_system' => $QST_system ) ) );
251
+	public function get_Question_ID_from_system_string($QST_system) {
252
+		 return $this->get_var(array(array('QST_system' => $QST_system)));
253 253
 	}
254 254
 
255 255
 
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function get_latest_question_order() {
263 263
 		$columns_to_select = array(
264
-			'max_order' => array("MAX(QST_order)","%d")
264
+			'max_order' => array("MAX(QST_order)", "%d")
265 265
 		);
266
-		$max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select );
267
-		return isset( $max[0], $max[0]['max_order'] ) ? $max[0]['max_order'] : 0;
266
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
267
+		return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
268 268
 	}
269 269
 
270 270
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 * @param string $system_question_value
294 294
 	 * @return int|float
295 295
 	 */
296
-	public function absolute_max_for_system_question( $system_question_value ) {
296
+	public function absolute_max_for_system_question($system_question_value) {
297 297
 		$maxes = $this->system_question_maxes();
298
-		if( isset( $maxes[ $system_question_value ] ) ) {
299
-			return $maxes[ $system_question_value ];
298
+		if (isset($maxes[$system_question_value])) {
299
+			return $maxes[$system_question_value];
300 300
 		} else {
301 301
 			return EE_INF;
302 302
 		}
Please login to merge, or discard this patch.