@@ -1,5 +1,5 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
| 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(); |
@@ -429,18 +429,18 @@ discard block |
||
| 429 | 429 | EE_Registry::instance()->load_helper('HTML'); |
| 430 | 430 | $descriptions = ''; |
| 431 | 431 | $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
| 432 | - foreach ( $question_type_descriptions as $type => $question_type_description ) { |
|
| 433 | - if ( $type == 'HTML_TEXTAREA' ) { |
|
| 432 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
| 433 | + if ($type == 'HTML_TEXTAREA') { |
|
| 434 | 434 | $html = new EE_Simple_HTML_Validation_Strategy(); |
| 435 | 435 | $question_type_description .= sprintf( |
| 436 | - __( '%1$s(allowed tags: %2$s)', 'event_espresso' ), |
|
| 436 | + __('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
| 437 | 437 | '<br/>', |
| 438 | 438 | $html->get_list_of_allowed_tags() |
| 439 | 439 | ); |
| 440 | 440 | } |
| 441 | 441 | $descriptions .= EEH_HTML::p( |
| 442 | 442 | $question_type_description, |
| 443 | - 'question_type_description-' . $type, |
|
| 443 | + 'question_type_description-'.$type, |
|
| 444 | 444 | 'question_type_description description', |
| 445 | 445 | 'display:none;' |
| 446 | 446 | ); |
@@ -454,58 +454,58 @@ discard block |
||
| 454 | 454 | * @param bool|true $new_question |
| 455 | 455 | * @throws \EE_Error |
| 456 | 456 | */ |
| 457 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
| 458 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 459 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
| 460 | - if($new_question){ |
|
| 461 | - $ID=$this->_question_model->insert($set_column_values); |
|
| 457 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
| 458 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 459 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
| 460 | + if ($new_question) { |
|
| 461 | + $ID = $this->_question_model->insert($set_column_values); |
|
| 462 | 462 | $success = $ID ? true : false; |
| 463 | 463 | $action_desc = 'added'; |
| 464 | - }else{ |
|
| 465 | - $ID=absint($this->_req_data['QST_ID']); |
|
| 466 | - $pk=$this->_question_model->primary_key_name(); |
|
| 467 | - $wheres=array($pk=>$ID); |
|
| 464 | + } else { |
|
| 465 | + $ID = absint($this->_req_data['QST_ID']); |
|
| 466 | + $pk = $this->_question_model->primary_key_name(); |
|
| 467 | + $wheres = array($pk=>$ID); |
|
| 468 | 468 | unset($set_column_values[$pk]); |
| 469 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
| 470 | - $action_desc='updated'; |
|
| 469 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
| 470 | + $action_desc = 'updated'; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if ($ID){ |
|
| 473 | + if ($ID) { |
|
| 474 | 474 | //save the related options |
| 475 | 475 | //trash removed options, save old ones |
| 476 | 476 | //get list of all options |
| 477 | 477 | /** @type EE_Question $question */ |
| 478 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
| 479 | - $options=$question->options(); |
|
| 480 | - if(! empty($options)){ |
|
| 481 | - foreach($options as $option_ID=>$option){ |
|
| 482 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
| 483 | - if($option_req_index!==FALSE){ |
|
| 478 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
| 479 | + $options = $question->options(); |
|
| 480 | + if ( ! empty($options)) { |
|
| 481 | + foreach ($options as $option_ID=>$option) { |
|
| 482 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
| 483 | + if ($option_req_index !== FALSE) { |
|
| 484 | 484 | $option->save($this->_req_data['question_options'][$option_req_index]); |
| 485 | - }else{ |
|
| 485 | + } else { |
|
| 486 | 486 | //not found, remove it |
| 487 | 487 | $option->delete(); |
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | //save new related options |
| 492 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
| 493 | - 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! |
|
| 494 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
| 495 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
| 492 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
| 493 | + 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! |
|
| 494 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
| 495 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
| 496 | 496 | } |
| 497 | - $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())); |
|
| 497 | + $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())); |
|
| 498 | 498 | $new_option->save(); |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
| 503 | - if ( $success !== FALSE ) { |
|
| 504 | - $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() ); |
|
| 505 | - EE_Error::add_success( $msg ); |
|
| 502 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
| 503 | + if ($success !== FALSE) { |
|
| 504 | + $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()); |
|
| 505 | + EE_Error::add_success($msg); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
| 508 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | |
@@ -518,10 +518,10 @@ discard block |
||
| 518 | 518 | * @param int $ID of the question option to find |
| 519 | 519 | * @return int index in question_options array if successful, FALSE if unsuccessful |
| 520 | 520 | */ |
| 521 | - protected function _get_option_req_data_index($ID){ |
|
| 522 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
| 523 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
| 524 | - if( array_key_exists('QSO_ID',$option_data) && (int)$option_data['QSO_ID'] === $ID ){ |
|
| 521 | + protected function _get_option_req_data_index($ID) { |
|
| 522 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
| 523 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
| 524 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
| 525 | 525 | return $num; |
| 526 | 526 | } |
| 527 | 527 | } |
@@ -543,25 +543,25 @@ discard block |
||
| 543 | 543 | * @param int $current_page |
| 544 | 544 | * @return array lik EEM_Base::get_all's $query_params parameter |
| 545 | 545 | */ |
| 546 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
| 546 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
| 547 | 547 | $query_params = array(); |
| 548 | - $offset=($current_page-1)*$per_page; |
|
| 549 | - $query_params['limit']=array($offset,$per_page); |
|
| 550 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
| 548 | + $offset = ($current_page - 1) * $per_page; |
|
| 549 | + $query_params['limit'] = array($offset, $per_page); |
|
| 550 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
| 551 | 551 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
| 552 | 552 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
| 553 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
| 554 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
| 555 | - if(! empty($search_string)){ |
|
| 556 | - if($model instanceof EEM_Question_Group){ |
|
| 557 | - $query_params[0]=array( |
|
| 553 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
| 554 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
| 555 | + if ( ! empty($search_string)) { |
|
| 556 | + if ($model instanceof EEM_Question_Group) { |
|
| 557 | + $query_params[0] = array( |
|
| 558 | 558 | 'OR'=>array( |
| 559 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
| 560 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
| 559 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
| 560 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
| 561 | 561 | ); |
| 562 | - }else{ |
|
| 563 | - $query_params[0]=array( |
|
| 564 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
| 562 | + } else { |
|
| 563 | + $query_params[0] = array( |
|
| 564 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
| 565 | 565 | ); |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -609,13 +609,13 @@ discard block |
||
| 609 | 609 | * @param bool|false $count |
| 610 | 610 | * @return \EE_Soft_Delete_Base_Class[]|int |
| 611 | 611 | */ |
| 612 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
| 612 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
| 613 | 613 | $QST = EEM_Question::instance(); |
| 614 | 614 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
| 615 | - if ($count){ |
|
| 616 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
| 615 | + if ($count) { |
|
| 616 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
| 617 | 617 | $results = $QST->count($where); |
| 618 | - }else{ |
|
| 618 | + } else { |
|
| 619 | 619 | $results = $QST->get_all($query_params); |
| 620 | 620 | } |
| 621 | 621 | return $results; |
@@ -630,10 +630,10 @@ discard block |
||
| 630 | 630 | * @param bool|false $count |
| 631 | 631 | * @return \EE_Soft_Delete_Base_Class[]|int |
| 632 | 632 | */ |
| 633 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
| 634 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
| 635 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
| 636 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
| 633 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
| 634 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
| 635 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
| 636 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
| 637 | 637 | return $questions; |
| 638 | 638 | } |
| 639 | 639 | |
@@ -645,12 +645,12 @@ discard block |
||
| 645 | 645 | * @param bool|false $count |
| 646 | 646 | * @return \EE_Soft_Delete_Base_Class[] |
| 647 | 647 | */ |
| 648 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
| 648 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
| 649 | 649 | /** @type EEM_Question_Group $questionGroupModel */ |
| 650 | 650 | $questionGroupModel = EEM_Question_Group::instance(); |
| 651 | 651 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
| 652 | 652 | return $questionGroupModel->get_all( |
| 653 | - $this->get_query_params( $questionGroupModel, $per_page, $current_page ) |
|
| 653 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
| 654 | 654 | ); |
| 655 | 655 | } |
| 656 | 656 | |
@@ -245,13 +245,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | * @return EE_Form_Section_Proper |
| 934 | 934 | */ |
| 935 | 935 | protected function _email_validation_settings_form() { |
| 936 | - return new EE_Form_Section_Proper( |
|
| 936 | + return new EE_Form_Section_Proper( |
|
| 937 | 937 | array( |
| 938 | 938 | 'name' => 'email_validation_settings', |
| 939 | 939 | 'html_id' => 'email_validation_settings', |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | ), |
| 952 | 952 | array( |
| 953 | 953 | 'html_label_text' => __( 'Email Validation Level', 'event_espresso' ) |
| 954 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
| 954 | + . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
| 955 | 955 | 'html_help_text' => __( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional 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'), |
| 956 | 956 | 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
| 957 | 957 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
@@ -973,8 +973,8 @@ discard block |
||
| 973 | 973 | * @return \EE_Registration_Config |
| 974 | 974 | */ |
| 975 | 975 | public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
| 976 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
| 977 | - try { |
|
| 976 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
| 977 | + try { |
|
| 978 | 978 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
| 979 | 979 | // if not displaying a form, then check for form submission |
| 980 | 980 | if ( $email_validation_settings_form->was_submitted() ) { |
@@ -985,80 +985,80 @@ discard block |
||
| 985 | 985 | // grab validated data from form |
| 986 | 986 | $valid_data = $email_validation_settings_form->valid_data(); |
| 987 | 987 | if ( isset( $valid_data['email_validation_level'] ) ) { |
| 988 | - $email_validation_level = $valid_data['email_validation_level']; |
|
| 989 | - // now if they want to use international email addresses |
|
| 990 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
| 991 | - // in case we need to reset their email validation level, |
|
| 992 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
| 993 | - // if so, then reset it back to "basic" since that is the only other option |
|
| 994 | - // that, despite offering poor validation, supports i18n email addresses |
|
| 995 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
| 996 | - $prev_email_validation_level = 'basic'; |
|
| 997 | - } |
|
| 998 | - // first check that PCRE is enabled |
|
| 999 | - if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
| 1000 | - EE_Error::add_error( |
|
| 1001 | - sprintf( |
|
| 1002 | - esc_html__( |
|
| 1003 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
| 1004 | - 'event_espresso' |
|
| 1005 | - ), |
|
| 1006 | - '<br />' |
|
| 1007 | - ), |
|
| 1008 | - __FILE__, |
|
| 1009 | - __FUNCTION__, |
|
| 1010 | - __LINE__ |
|
| 1011 | - ); |
|
| 1012 | - // reset email validation level to previous value |
|
| 1013 | - $email_validation_level = $prev_email_validation_level; |
|
| 1014 | - } else { |
|
| 1015 | - // PCRE support is enabled, but let's still |
|
| 1016 | - // perform a test to see if the server will support it |
|
| 1017 | - try { |
|
| 1018 | - // need to save the updated validation level to the config, |
|
| 1019 | - // so that the validation strategy picks it up. |
|
| 1020 | - // this will get bumped back down if it doesn't work |
|
| 1021 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
| 1022 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
| 1023 | - $i18n_email_address = apply_filters( |
|
| 1024 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
| 1025 | - 'jägerjü[email protected]' |
|
| 1026 | - ); |
|
| 1027 | - $email_validator->validate($i18n_email_address); |
|
| 1028 | - } catch (Exception $e) { |
|
| 1029 | - EE_Error::add_error( |
|
| 1030 | - sprintf( |
|
| 1031 | - esc_html__( |
|
| 1032 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
| 1033 | - 'event_espresso' |
|
| 1034 | - ), |
|
| 1035 | - '<br />', |
|
| 1036 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
| 1037 | - ), |
|
| 1038 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1039 | - ); |
|
| 1040 | - // reset email validation level to previous value |
|
| 1041 | - $email_validation_level = $prev_email_validation_level; |
|
| 1042 | - } |
|
| 1043 | - } |
|
| 1044 | - } |
|
| 1045 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
| 1046 | - |
|
| 1047 | - } else { |
|
| 988 | + $email_validation_level = $valid_data['email_validation_level']; |
|
| 989 | + // now if they want to use international email addresses |
|
| 990 | + if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
| 991 | + // in case we need to reset their email validation level, |
|
| 992 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
| 993 | + // if so, then reset it back to "basic" since that is the only other option |
|
| 994 | + // that, despite offering poor validation, supports i18n email addresses |
|
| 995 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
| 996 | + $prev_email_validation_level = 'basic'; |
|
| 997 | + } |
|
| 998 | + // first check that PCRE is enabled |
|
| 999 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
| 1000 | + EE_Error::add_error( |
|
| 1001 | + sprintf( |
|
| 1002 | + esc_html__( |
|
| 1003 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
| 1004 | + 'event_espresso' |
|
| 1005 | + ), |
|
| 1006 | + '<br />' |
|
| 1007 | + ), |
|
| 1008 | + __FILE__, |
|
| 1009 | + __FUNCTION__, |
|
| 1010 | + __LINE__ |
|
| 1011 | + ); |
|
| 1012 | + // reset email validation level to previous value |
|
| 1013 | + $email_validation_level = $prev_email_validation_level; |
|
| 1014 | + } else { |
|
| 1015 | + // PCRE support is enabled, but let's still |
|
| 1016 | + // perform a test to see if the server will support it |
|
| 1017 | + try { |
|
| 1018 | + // need to save the updated validation level to the config, |
|
| 1019 | + // so that the validation strategy picks it up. |
|
| 1020 | + // this will get bumped back down if it doesn't work |
|
| 1021 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
| 1022 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
| 1023 | + $i18n_email_address = apply_filters( |
|
| 1024 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
| 1025 | + 'jägerjü[email protected]' |
|
| 1026 | + ); |
|
| 1027 | + $email_validator->validate($i18n_email_address); |
|
| 1028 | + } catch (Exception $e) { |
|
| 1029 | + EE_Error::add_error( |
|
| 1030 | + sprintf( |
|
| 1031 | + esc_html__( |
|
| 1032 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
| 1033 | + 'event_espresso' |
|
| 1034 | + ), |
|
| 1035 | + '<br />', |
|
| 1036 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
| 1037 | + ), |
|
| 1038 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1039 | + ); |
|
| 1040 | + // reset email validation level to previous value |
|
| 1041 | + $email_validation_level = $prev_email_validation_level; |
|
| 1042 | + } |
|
| 1043 | + } |
|
| 1044 | + } |
|
| 1045 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
| 1046 | + |
|
| 1047 | + } else { |
|
| 1048 | 1048 | EE_Error::add_error( |
| 1049 | 1049 | __( |
| 1050 | 1050 | 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
| 1051 | 1051 | 'event_espresso' |
| 1052 | 1052 | ), |
| 1053 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1054 | - ); |
|
| 1053 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1054 | + ); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | } else { |
| 1057 | 1057 | if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
| 1058 | 1058 | EE_Error::add_error( |
| 1059 | 1059 | $email_validation_settings_form->submission_error_message(), |
| 1060 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1061 | - ); |
|
| 1060 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1061 | + ); |
|
| 1062 | 1062 | } |
| 1063 | 1063 | } |
| 1064 | 1064 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,41 +520,41 @@ discard block |
||
| 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; |
|
| 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 | 526 | |
| 527 | - switch( $this->_req_action ) { |
|
| 527 | + switch ($this->_req_action) { |
|
| 528 | 528 | case 'add_question_group' : |
| 529 | - $this->_admin_page_title = esc_html__( 'Add Question Group', 'event_espresso' ); |
|
| 529 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
| 530 | 530 | break; |
| 531 | 531 | case 'edit_question_group' : |
| 532 | - $this->_admin_page_title = esc_html__( 'Edit Question Group', 'event_espresso' ); |
|
| 532 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
| 533 | 533 | break; |
| 534 | 534 | default : |
| 535 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
| 535 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 536 | 536 | } |
| 537 | 537 | // add ID to title if editing |
| 538 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
| 539 | - if($ID){ |
|
| 538 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
| 539 | + if ($ID) { |
|
| 540 | 540 | /** @var EE_Question_Group $questionGroup */ |
| 541 | - $questionGroup=$this->_question_group_model->get_one_by_ID( $ID); |
|
| 542 | - $additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
| 541 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
| 542 | + $additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
| 543 | 543 | $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
| 544 | - }else{ |
|
| 544 | + } else { |
|
| 545 | 545 | /** @var EE_Question_Group $questionGroup */ |
| 546 | 546 | $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
| 547 | 547 | $questionGroup->set_order_to_latest(); |
| 548 | 548 | $this->_set_add_edit_form_tags('insert_question_group'); |
| 549 | 549 | } |
| 550 | 550 | $this->_template_args['values'] = $this->_yes_no_values; |
| 551 | - $this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group(); |
|
| 552 | - $this->_template_args['QSG_ID']=$ID ? $ID : TRUE; |
|
| 553 | - $this->_template_args['question_group']=$questionGroup; |
|
| 551 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
| 552 | + $this->_template_args['QSG_ID'] = $ID ? $ID : TRUE; |
|
| 553 | + $this->_template_args['question_group'] = $questionGroup; |
|
| 554 | 554 | |
| 555 | - $redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url ); |
|
| 556 | - $this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL ); |
|
| 557 | - $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 ); |
|
| 555 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
| 556 | + $this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL); |
|
| 557 | + $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); |
|
| 558 | 558 | |
| 559 | 559 | // the details template wrapper |
| 560 | 560 | $this->display_admin_page_with_sidebar(); |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | protected function _delete_question_groups() { |
| 567 | 567 | $success = $this->_delete_items($this->_question_group_model); |
| 568 | - $this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' )); |
|
| 568 | + $this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash')); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -573,71 +573,71 @@ discard block |
||
| 573 | 573 | /** |
| 574 | 574 | * @param bool $new_question_group |
| 575 | 575 | */ |
| 576 | - protected function _insert_or_update_question_group( $new_question_group = TRUE) { |
|
| 577 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 578 | - $set_column_values=$this->_set_column_values_for($this->_question_group_model); |
|
| 579 | - if ( $new_question_group ){ |
|
| 576 | + protected function _insert_or_update_question_group($new_question_group = TRUE) { |
|
| 577 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 578 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
| 579 | + if ($new_question_group) { |
|
| 580 | 580 | $QSG_ID = $this->_question_group_model->insert($set_column_values); |
| 581 | 581 | $success = $QSG_ID ? 1 : 0; |
| 582 | 582 | } else { |
| 583 | 583 | $QSG_ID = absint($this->_req_data['QSG_ID']); |
| 584 | - unset( $set_column_values[ 'QSG_ID' ] ); |
|
| 585 | - $success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID ))); |
|
| 584 | + unset($set_column_values['QSG_ID']); |
|
| 585 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
| 586 | 586 | } |
| 587 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone ); |
|
| 587 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone); |
|
| 588 | 588 | // update the existing related questions |
| 589 | 589 | // 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) |
| 590 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) { |
|
| 590 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
| 591 | 591 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
| 592 | - EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID )))); |
|
| 592 | + EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID)))); |
|
| 593 | 593 | } |
| 594 | 594 | /** @type EE_Question_Group $question_group */ |
| 595 | - $question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID ); |
|
| 595 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
| 596 | 596 | $questions = $question_group->questions(); |
| 597 | 597 | // make sure system phone question is added to list of questions for this group |
| 598 | - if ( ! isset( $questions[$phone_question_id ] )) { |
|
| 599 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id ); |
|
| 598 | + if ( ! isset($questions[$phone_question_id])) { |
|
| 599 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - foreach( $questions as $question_ID => $question ){ |
|
| 602 | + foreach ($questions as $question_ID => $question) { |
|
| 603 | 603 | // first we always check for order. |
| 604 | - if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){ |
|
| 604 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
| 605 | 605 | //update question order |
| 606 | - $question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] ); |
|
| 606 | + $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // then we always check if adding or removing. |
| 610 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) { |
|
| 611 | - $question_group->add_question( $question_ID ); |
|
| 610 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
| 611 | + $question_group->add_question($question_ID); |
|
| 612 | 612 | } else { |
| 613 | 613 | // 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) |
| 614 | 614 | if ( |
| 615 | 615 | in_array( |
| 616 | 616 | $question->system_ID(), |
| 617 | - EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() ) |
|
| 617 | + EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group()) |
|
| 618 | 618 | ) |
| 619 | 619 | ) { |
| 620 | 620 | continue; |
| 621 | 621 | } else { |
| 622 | - $question_group->remove_question( $question_ID ); |
|
| 622 | + $question_group->remove_question($question_ID); |
|
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | // save new related questions |
| 627 | - if ( isset( $this->_req_data['questions'] )) { |
|
| 628 | - foreach( $this->_req_data['questions'] as $QST_ID ){ |
|
| 629 | - $question_group->add_question( $QST_ID ); |
|
| 630 | - if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) { |
|
| 631 | - $question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] ); |
|
| 627 | + if (isset($this->_req_data['questions'])) { |
|
| 628 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
| 629 | + $question_group->add_question($QST_ID); |
|
| 630 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
| 631 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - if ( $success !== FALSE ) { |
|
| 637 | - $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() ); |
|
| 638 | - EE_Error::add_success( $msg ); |
|
| 636 | + if ($success !== FALSE) { |
|
| 637 | + $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()); |
|
| 638 | + EE_Error::add_success($msg); |
|
| 639 | 639 | } |
| 640 | - $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE); |
|
| 640 | + $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE); |
|
| 641 | 641 | |
| 642 | 642 | } |
| 643 | 643 | |
@@ -645,20 +645,20 @@ discard block |
||
| 645 | 645 | * duplicates a question and all its question options and redirects to the new question. |
| 646 | 646 | */ |
| 647 | 647 | public function _duplicate_question() { |
| 648 | - $question_ID = (int)$this->_req_data[ 'QST_ID' ]; |
|
| 649 | - $question = EEM_Question::instance()->get_one_by_ID( $question_ID ); |
|
| 650 | - if( $question instanceof EE_Question ) { |
|
| 648 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
| 649 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
| 650 | + if ($question instanceof EE_Question) { |
|
| 651 | 651 | $new_question = $question->duplicate(); |
| 652 | - if( $new_question instanceof EE_Question ) { |
|
| 653 | - $this->_redirect_after_action( true, __( 'Question', 'event_espresso' ), __( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE); |
|
| 652 | + if ($new_question instanceof EE_Question) { |
|
| 653 | + $this->_redirect_after_action(true, __('Question', 'event_espresso'), __('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE); |
|
| 654 | 654 | } else { |
| 655 | 655 | global $wpdb; |
| 656 | - 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__ ); |
|
| 657 | - $this->_redirect_after_action(false, '', '', array('action'=>'default'), false ); |
|
| 656 | + 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__); |
|
| 657 | + $this->_redirect_after_action(false, '', '', array('action'=>'default'), false); |
|
| 658 | 658 | } |
| 659 | 659 | } else { |
| 660 | - EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 661 | - $this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false ); |
|
| 660 | + EE_Error::add_error(sprintf(__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__); |
|
| 661 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | /** |
| 668 | 668 | * @param bool $trash |
| 669 | 669 | */ |
| 670 | - protected function _trash_or_restore_question_groups( $trash = TRUE) { |
|
| 671 | - $this->_trash_or_restore_items( $this->_question_group_model, $trash ); |
|
| 670 | + protected function _trash_or_restore_question_groups($trash = TRUE) { |
|
| 671 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | |
@@ -676,9 +676,9 @@ discard block |
||
| 676 | 676 | /** |
| 677 | 677 | *_trash_question |
| 678 | 678 | */ |
| 679 | - protected function _trash_question(){ |
|
| 680 | - $success=$this->_question_model->delete_by_ID( (int)$this->_req_data['QST_ID'] ); |
|
| 681 | - $query_args=array('action'=>'default','status'=>'all'); |
|
| 679 | + protected function _trash_question() { |
|
| 680 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
| 681 | + $query_args = array('action'=>'default', 'status'=>'all'); |
|
| 682 | 682 | $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
| 683 | 683 | } |
| 684 | 684 | |
@@ -687,8 +687,8 @@ discard block |
||
| 687 | 687 | /** |
| 688 | 688 | * @param bool $trash |
| 689 | 689 | */ |
| 690 | - protected function _trash_or_restore_questions( $trash=TRUE){ |
|
| 691 | - $this->_trash_or_restore_items( $this->_question_model, $trash ); |
|
| 690 | + protected function _trash_or_restore_questions($trash = TRUE) { |
|
| 691 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | |
@@ -700,21 +700,21 @@ discard block |
||
| 700 | 700 | *@param EEM_Soft_Delete_Base $model |
| 701 | 701 | * @param boolean $trash whether to trash or restore |
| 702 | 702 | */ |
| 703 | - private function _trash_or_restore_items( EEM_Soft_Delete_Base $model, $trash = TRUE ) { |
|
| 703 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = TRUE) { |
|
| 704 | 704 | |
| 705 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 705 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 706 | 706 | |
| 707 | 707 | $success = 1; |
| 708 | 708 | //Checkboxes |
| 709 | 709 | //echo "trash $trash"; |
| 710 | 710 | //var_dump($this->_req_data['checkbox']);die; |
| 711 | - if ( isset( $this->_req_data['checkbox'] )) { |
|
| 712 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) { |
|
| 711 | + if (isset($this->_req_data['checkbox'])) { |
|
| 712 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 713 | 713 | // if array has more than one element than success message should be plural |
| 714 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
| 714 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 715 | 715 | // cycle thru bulk action checkboxes |
| 716 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
| 717 | - if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) { |
|
| 716 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 717 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
| 718 | 718 | $success = 0; |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | } else { |
| 723 | 723 | // grab single id and delete |
| 724 | 724 | $ID = absint($this->_req_data['checkbox']); |
| 725 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
| 725 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
| 726 | 726 | $success = 0; |
| 727 | 727 | } |
| 728 | 728 | } |
@@ -730,25 +730,25 @@ discard block |
||
| 730 | 730 | } else { |
| 731 | 731 | // delete via trash link |
| 732 | 732 | // grab single id and delete |
| 733 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
| 734 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
| 733 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
| 734 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
| 735 | 735 | $success = 0; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | |
| 741 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
| 741 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) ); |
|
| 742 | 742 | //echo "action :$action"; |
| 743 | 743 | //$action = 'questions' ? 'default' : $action; |
| 744 | - if($trash){ |
|
| 744 | + if ($trash) { |
|
| 745 | 745 | $action_desc = 'trashed'; |
| 746 | 746 | $status = 'trash'; |
| 747 | - }else{ |
|
| 747 | + } else { |
|
| 748 | 748 | $action_desc = 'restored'; |
| 749 | 749 | $status = 'all'; |
| 750 | 750 | } |
| 751 | - $this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) ); |
|
| 751 | + $this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status)); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | |
@@ -759,16 +759,16 @@ discard block |
||
| 759 | 759 | * @param bool|false $count |
| 760 | 760 | * @return \EE_Soft_Delete_Base_Class[]|int |
| 761 | 761 | */ |
| 762 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
| 762 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
| 763 | 763 | $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
| 764 | 764 | |
| 765 | - if( $count ){ |
|
| 765 | + if ($count) { |
|
| 766 | 766 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
| 767 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
| 768 | - $results=$this->_question_model->count_deleted($where); |
|
| 769 | - }else{ |
|
| 767 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
| 768 | + $results = $this->_question_model->count_deleted($where); |
|
| 769 | + } else { |
|
| 770 | 770 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
| 771 | - $results=$this->_question_model->get_all_deleted($query_params); |
|
| 771 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
| 772 | 772 | } |
| 773 | 773 | return $results; |
| 774 | 774 | } |
@@ -781,13 +781,13 @@ discard block |
||
| 781 | 781 | * @param bool|false $count |
| 782 | 782 | * @return \EE_Soft_Delete_Base_Class[] |
| 783 | 783 | */ |
| 784 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
| 785 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
| 786 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
| 787 | - if ($count){ |
|
| 788 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
| 784 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
| 785 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
| 786 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
| 787 | + if ($count) { |
|
| 788 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
| 789 | 789 | $results = $questionGroupModel->count($where); |
| 790 | - }else{ |
|
| 790 | + } else { |
|
| 791 | 791 | $results = $questionGroupModel->get_all($query_params); |
| 792 | 792 | } |
| 793 | 793 | return $results; |
@@ -801,14 +801,14 @@ discard block |
||
| 801 | 801 | * @param bool $count |
| 802 | 802 | * @return \EE_Soft_Delete_Base_Class[]|int |
| 803 | 803 | */ |
| 804 | - public function get_trashed_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
| 805 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
| 806 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
| 807 | - if($count){ |
|
| 808 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
| 804 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
| 805 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
| 806 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
| 807 | + if ($count) { |
|
| 808 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
| 809 | 809 | $query_params['limit'] = NULL; |
| 810 | 810 | $results = $questionGroupModel->count_deleted($where); |
| 811 | - }else{ |
|
| 811 | + } else { |
|
| 812 | 812 | $results = $questionGroupModel->get_all_deleted($query_params); |
| 813 | 813 | } |
| 814 | 814 | return $results; |
@@ -821,32 +821,32 @@ discard block |
||
| 821 | 821 | */ |
| 822 | 822 | public function update_question_group_order() { |
| 823 | 823 | |
| 824 | - $success = __( 'Question group order was updated successfully.', 'event_espresso' ); |
|
| 824 | + $success = __('Question group order was updated successfully.', 'event_espresso'); |
|
| 825 | 825 | |
| 826 | 826 | // grab our row IDs |
| 827 | - $row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) |
|
| 828 | - ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) |
|
| 827 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
| 828 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
| 829 | 829 | : array(); |
| 830 | 830 | |
| 831 | - $perpage = !empty( $this->_req_data['perpage'] ) |
|
| 831 | + $perpage = ! empty($this->_req_data['perpage']) |
|
| 832 | 832 | ? (int) $this->_req_data['perpage'] |
| 833 | 833 | : NULL; |
| 834 | - $curpage = !empty( $this->_req_data['curpage'] ) |
|
| 834 | + $curpage = ! empty($this->_req_data['curpage']) |
|
| 835 | 835 | ? (int) $this->_req_data['curpage'] |
| 836 | 836 | : NULL; |
| 837 | 837 | |
| 838 | - if ( ! empty( $row_ids ) ) { |
|
| 838 | + if ( ! empty($row_ids)) { |
|
| 839 | 839 | //figure out where we start the row_id count at for the current page. |
| 840 | - $qsgcount = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage; |
|
| 840 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
| 841 | 841 | |
| 842 | - $row_count = count( $row_ids ); |
|
| 843 | - for( $i = 0; $i < $row_count; $i++ ) { |
|
| 842 | + $row_count = count($row_ids); |
|
| 843 | + for ($i = 0; $i < $row_count; $i++) { |
|
| 844 | 844 | //Update the questions when re-ordering |
| 845 | 845 | $updated = EEM_Question_Group::instance()->update( |
| 846 | - array( 'QSG_order' => $qsgcount ), |
|
| 847 | - array( array( 'QSG_ID' => $row_ids[ $i ] ) ) |
|
| 846 | + array('QSG_order' => $qsgcount), |
|
| 847 | + array(array('QSG_ID' => $row_ids[$i])) |
|
| 848 | 848 | ); |
| 849 | - if ( $updated === false ) { |
|
| 849 | + if ($updated === false) { |
|
| 850 | 850 | $success = false; |
| 851 | 851 | } |
| 852 | 852 | $qsgcount++; |
@@ -856,10 +856,10 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | $errors = ! $success |
| 859 | - ? __( 'An error occurred. The question group order was not updated.', 'event_espresso' ) |
|
| 859 | + ? __('An error occurred. The question group order was not updated.', 'event_espresso') |
|
| 860 | 860 | : false; |
| 861 | 861 | |
| 862 | - echo json_encode( array( 'return_data' => false, 'success' => $success, 'errors' => $errors )); |
|
| 862 | + echo json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
| 863 | 863 | die(); |
| 864 | 864 | |
| 865 | 865 | } |
@@ -878,17 +878,17 @@ discard block |
||
| 878 | 878 | $this->_template_args['values'] = $this->_yes_no_values; |
| 879 | 879 | add_action( |
| 880 | 880 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
| 881 | - array( $this, 'email_validation_settings_form' ), |
|
| 881 | + array($this, 'email_validation_settings_form'), |
|
| 882 | 882 | 2 |
| 883 | 883 | ); |
| 884 | - $this->_template_args = (array)apply_filters( |
|
| 884 | + $this->_template_args = (array) apply_filters( |
|
| 885 | 885 | 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
| 886 | 886 | $this->_template_args |
| 887 | 887 | ); |
| 888 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
| 889 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 888 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
| 889 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
| 890 | 890 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 891 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
| 891 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
| 892 | 892 | $this->_template_args, |
| 893 | 893 | TRUE |
| 894 | 894 | ); |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | EE_Registry::instance()->CFG, |
| 910 | 910 | __FILE__, __FUNCTION__, __LINE__ |
| 911 | 911 | ); |
| 912 | - $this->_redirect_after_action( $success, __('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) ); |
|
| 912 | + $this->_redirect_after_action($success, __('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings')); |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | |
@@ -940,20 +940,20 @@ discard block |
||
| 940 | 940 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
| 941 | 941 | 'subsections' => array( |
| 942 | 942 | 'email_validation_hdr' => new EE_Form_Section_HTML( |
| 943 | - EEH_HTML::h2( __( 'Email Validation Settings', 'event_espresso' ) ) |
|
| 943 | + EEH_HTML::h2(__('Email Validation Settings', 'event_espresso')) |
|
| 944 | 944 | ), |
| 945 | 945 | 'email_validation_level' => new EE_Select_Input( |
| 946 | 946 | array( |
| 947 | - 'basic' => __( 'Basic', 'event_espresso' ), |
|
| 948 | - 'wp_default' => __( 'WordPress Default', 'event_espresso' ), |
|
| 949 | - 'i18n' => __( 'International', 'event_espresso' ), |
|
| 950 | - 'i18n_dns' => __( 'International + DNS Check', 'event_espresso' ), |
|
| 947 | + 'basic' => __('Basic', 'event_espresso'), |
|
| 948 | + 'wp_default' => __('WordPress Default', 'event_espresso'), |
|
| 949 | + 'i18n' => __('International', 'event_espresso'), |
|
| 950 | + 'i18n_dns' => __('International + DNS Check', 'event_espresso'), |
|
| 951 | 951 | ), |
| 952 | 952 | array( |
| 953 | - 'html_label_text' => __( 'Email Validation Level', 'event_espresso' ) |
|
| 954 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
| 955 | - 'html_help_text' => __( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional 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'), |
|
| 956 | - 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
| 953 | + 'html_label_text' => __('Email Validation Level', 'event_espresso') |
|
| 954 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
| 955 | + 'html_help_text' => __('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional 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'), |
|
| 956 | + 'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
| 957 | 957 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
| 958 | 958 | : 'wp_default', |
| 959 | 959 | 'required' => false |
@@ -972,27 +972,27 @@ discard block |
||
| 972 | 972 | * @param \EE_Registration_Config $EE_Registration_Config |
| 973 | 973 | * @return \EE_Registration_Config |
| 974 | 974 | */ |
| 975 | - public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
| 975 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
| 976 | 976 | $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
| 977 | 977 | try { |
| 978 | 978 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
| 979 | 979 | // if not displaying a form, then check for form submission |
| 980 | - if ( $email_validation_settings_form->was_submitted() ) { |
|
| 980 | + if ($email_validation_settings_form->was_submitted()) { |
|
| 981 | 981 | // capture form data |
| 982 | 982 | $email_validation_settings_form->receive_form_submission(); |
| 983 | 983 | // validate form data |
| 984 | - if ( $email_validation_settings_form->is_valid() ) { |
|
| 984 | + if ($email_validation_settings_form->is_valid()) { |
|
| 985 | 985 | // grab validated data from form |
| 986 | 986 | $valid_data = $email_validation_settings_form->valid_data(); |
| 987 | - if ( isset( $valid_data['email_validation_level'] ) ) { |
|
| 987 | + if (isset($valid_data['email_validation_level'])) { |
|
| 988 | 988 | $email_validation_level = $valid_data['email_validation_level']; |
| 989 | 989 | // now if they want to use international email addresses |
| 990 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
| 990 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
| 991 | 991 | // in case we need to reset their email validation level, |
| 992 | 992 | // make sure that the previous value wasn't already set to one of the i18n options. |
| 993 | 993 | // if so, then reset it back to "basic" since that is the only other option |
| 994 | 994 | // that, despite offering poor validation, supports i18n email addresses |
| 995 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
| 995 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
| 996 | 996 | $prev_email_validation_level = 'basic'; |
| 997 | 997 | } |
| 998 | 998 | // first check that PCRE is enabled |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | ); |
| 1055 | 1055 | } |
| 1056 | 1056 | } else { |
| 1057 | - if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
|
| 1057 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
| 1058 | 1058 | EE_Error::add_error( |
| 1059 | 1059 | $email_validation_settings_form->submission_error_message(), |
| 1060 | 1060 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | } |
| 1063 | 1063 | } |
| 1064 | 1064 | } |
| 1065 | - } catch ( EE_Error $e ) { |
|
| 1065 | + } catch (EE_Error $e) { |
|
| 1066 | 1066 | $e->get_error(); |
| 1067 | 1067 | } |
| 1068 | 1068 | return $EE_Registration_Config; |