public function test_get_answer_value_to_question()
 {
     $r = $this->new_model_obj_with_dependencies('Registration');
     $a = $this->new_model_obj_with_dependencies('Answer', array('REG_ID' => $r->ID()));
     $this->assertEquals($a->value(), EEM_Answer::instance()->get_answer_value_to_question($r, $a->question_ID(), false));
     $this->assertEquals($r->attendee()->fname(), EEM_Answer::instance()->get_answer_value_to_question($r, EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_fname)));
 }
 /**
  * test that questions aren't editable until you're logged in,
  * then you can only edit your own non-system questions,
  * and then you can edit others if you have that cap,
  * and then you can edit others if you have that cap
  */
 function test_get_all__caps__edit()
 {
     //remove all questions currently existing
     EEM_Question::instance()->delete_permanently(EEM_Question::instance()->alter_query_params_so_deleted_and_undeleted_items_included(), false);
     $this->assertEquals(0, EEM_Question::instance()->count(EEM_Question::instance()->alter_query_params_so_deleted_and_undeleted_items_included()));
     global $current_user;
     $user = $this->factory->user->create_and_get();
     $this->assertEquals(0, EEM_Question::instance()->count(array('caps' => EEM_Base::caps_edit)));
     //now log in and see I can edit my own
     $current_user = $user;
     $user->add_cap('ee_edit_questions');
     $q1 = $this->new_model_obj_with_dependencies('Question', array('QST_system' => '', 'QST_wp_user' => $user->ID));
     $q2_system = $this->new_model_obj_with_dependencies('Question', array('QST_system' => 'something', 'QST_wp_user' => $user->ID));
     $q3_others = $this->new_model_obj_with_dependencies('Question', array('QST_system' => '', 'QST_wp_user' => 9999));
     $q4_others_system = $this->new_model_obj_with_dependencies('Question', array('QST_system' => 'somethingelse', 'QST_wp_user' => 9999));
     $i_can_edit = EEM_Question::instance()->get_all(array('caps' => EEM_Base::caps_edit));
     $this->assertEquals($q1, reset($i_can_edit));
     $this->assertEquals($q3_others, next($i_can_edit));
     $this->assertEquals(2, count($i_can_edit));
     //now give them the ability to edit system questions
     $user->add_cap('ee_edit_system_questions');
     $i_can_edit = EEM_Question::instance()->get_all(array('caps' => EEM_Base::caps_edit));
     $this->assertEquals($q1, reset($i_can_edit));
     $this->assertEquals($q2_system, next($i_can_edit));
     $this->assertEquals($q3_others, next($i_can_edit));
     $this->assertEquals($q4_others_system, next($i_can_edit));
     $this->assertEquals(4, count($i_can_edit));
 }
 function test_get_registration_question_answer_object()
 {
     $r = $this->new_model_obj_with_dependencies('Registration');
     $a = $this->new_model_obj_with_dependencies('Answer', array('REG_ID' => $r->ID()));
     $q = EEM_Question::instance()->get_one_by_ID($a->question_ID());
     $this->assertNotNull($q);
     $this->assertEquals($a, EEM_Answer::instance()->get_registration_question_answer_object($r, $a->question_ID()));
 }
 /**
  *		This function is a singleton method used to instantiate the EEM_Attendee object
  *
  *		@access public
  *		@return EEM_Question instance
  */
 public static function instance()
 {
     // check if instance of EEM_Attendee already exists
     if (self::$_instance === NULL) {
         // instantiate Espresso_model
         self::$_instance = new self();
     }
     // EEM_Attendee object
     return self::$_instance;
 }
 function test_answer_value_to_question()
 {
     $r = $this->new_model_obj_with_dependencies('Registration');
     $q1 = $this->new_model_obj_with_dependencies('Question');
     //also grab the default firstname question
     $q2 = EEM_Question::instance()->get_one_by_ID(EEM_Attendee::fname_question_id);
     $this->assertNotNull($q2);
     $a1 = $this->new_model_obj_with_dependencies('Answer', array('REG_ID' => $r->ID(), 'QST_ID' => $q1->ID()));
     $this->assertEquals($a1->value(), $r->answer_value_to_question($q1, false));
     $this->assertEquals($r->attendee()->fname(), $r->answer_value_to_question($q2, false));
 }
 /**
  * Test that message templates are controlled properly by caps
  * and then you can edit others if you have that cap,
  * and then you can edit others if you have that cap
  */
 function test_get_all__caps()
 {
     //remove all questions currently existing
     EEM_Message_Template::instance()->delete(array(), false);
     $this->assertEquals(0, EEM_Message_Template::instance()->count());
     EEM_Message_Template_Group::instance()->delete_permanently(EEM_Message_Template_Group::instance()->alter_query_params_so_deleted_and_undeleted_items_included(), false);
     $this->assertEquals(0, EEM_Message_Template_Group::instance()->count());
     global $current_user;
     $user = $this->factory->user->create_and_get();
     $this->assertEquals(0, EEM_Question::instance()->count(array('caps' => EEM_Base::caps_read_admin)));
     //now log in and see I can edit my own
     $current_user = $user;
     $user->add_cap('ee_read_messages');
     $mtg1 = $this->new_model_obj_with_dependencies('Message_Template_Group', array('MTP_is_global' => false, 'MTP_user_id' => $user->ID));
     $mt1 = $this->new_model_obj_with_dependencies('Message_Template', array('GRP_ID' => $mtg1->ID()));
     $mtg2_others = $this->new_model_obj_with_dependencies('Message_Template_Group', array('MTP_is_global' => false, 'MTP_user_id' => 9999));
     $mt2_others = $this->new_model_obj_with_dependencies('Message_Template', array('GRP_ID' => $mtg2_others->ID()));
     $mtg3_global = $this->new_model_obj_with_dependencies('Message_Template_Group', array('MTP_is_global' => true, 'MTP_user_id' => 9999));
     $mt3_global = $this->new_model_obj_with_dependencies('Message_Template', array('GRP_ID' => $mtg3_global->ID()));
     $i_can_edit = EEM_Message_Template::instance()->get_all(array('caps' => EEM_Base::caps_read_admin));
     $this->assertEquals($mt1, reset($i_can_edit));
     $this->assertEquals(1, count($i_can_edit));
     //now give them the ability to read others messages
     $user->add_cap('ee_read_others_messages');
     $i_can_edit = EEM_Message_Template::instance()->get_all(array('caps' => EEM_Base::caps_read_admin));
     $this->assertEquals($mt1, reset($i_can_edit));
     $this->assertEquals($mt2_others, next($i_can_edit));
     $this->assertEquals(2, count($i_can_edit));
     //now let them read global message
     $user->add_cap('ee_read_global_messages');
     $i_can_edit = EEM_Message_Template::instance()->get_all(array('caps' => EEM_Base::caps_read_admin, 'order_by' => array('MTP_ID' => 'ASC')));
     $this->assertEquals($mt1, reset($i_can_edit));
     $this->assertEquals($mt2_others, next($i_can_edit));
     $this->assertEquals($mt3_global, next($i_can_edit));
     $this->assertEquals(3, count($i_can_edit));
 }
 public function test_alter_query_params_to_only_include_mine__not_logged_in()
 {
     $this->assertFalse(is_user_logged_in());
     $this->assertEquals(array(array('QST_wp_user' => get_current_user_id())), EEM_Question::instance()->alter_query_params_to_only_include_mine());
 }
 /**
  * set property values for question form input
  * @access public
  * @param    string $property
  * @param    mixed  $value
  * @return mixed
  */
 public function set($property = NULL, $value = NULL)
 {
     if (!empty($property)) {
         if (EEM_Question::instance()->has_field($property)) {
             $this->_QST->set($property, $value);
         } else {
             if (EEM_Answer::instance()->has_field($property)) {
                 $this->_ANS->set($property, $value);
             } else {
                 if ($this->_question_form_input_property_exists(__CLASS__, $property)) {
                     echo "<hr>{$property} is a prop of QFI";
                     $this->{$property} = $value;
                     return TRUE;
                 }
             }
         }
     }
     return NULL;
 }
 /**
  * @param            $per_page
  * @param int        $current_page
  * @param bool|false $count
  * @return \EE_Soft_Delete_Base_Class[]|int
  */
 public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE)
 {
     $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
     $where = isset($query_params[0]) ? array($query_params[0]) : array();
     $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
     return $questions;
 }
 /**
  * Gets all the questions which are NOT part of this question group.
  * @param  mixed $question_IDS_in_group if empty array then all questions returned.  if FALSE then we first get questions in this group and exclude them from questions get all. IF empty array then we just return all questions.
  * @return EE_Question[]
  */
 public function questions_not_in_group($question_IDS_in_group = FALSE)
 {
     if ($question_IDS_in_group === FALSE) {
         $questions = $this->questions();
         $question_IDS_in_group = !empty($questions) ? array_keys($questions) : array();
     }
     $_where = !empty($question_IDS_in_group) ? array('QST_ID' => array('not_in', $question_IDS_in_group)) : array();
     return EEM_Question::instance()->get_all(array($_where, 'order_by' => array('QST_ID' => 'ASC')));
 }
 /**
  * initialize_system_questions
  *
  * 	@access public
  * 	@static
  * 	@return void
  */
 public static function initialize_system_questions()
 {
     // QUESTION GROUPS
     global $wpdb;
     $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
     $SQL = "SELECT QSG_system FROM {$table_name} WHERE QSG_system != 0";
     // what we have
     $question_groups = $wpdb->get_col($SQL);
     // check the response
     $question_groups = is_array($question_groups) ? $question_groups : array();
     // what we should have
     $QSG_systems = array(1, 2);
     // loop thru what we should have and compare to what we have
     foreach ($QSG_systems as $QSG_system) {
         // reset values array
         $QSG_values = array();
         // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
         if (!in_array("{$QSG_system}", $question_groups)) {
             // add it
             switch ($QSG_system) {
                 case 1:
                     $QSG_values = array('QSG_name' => __('Personal Information', 'event_espresso'), 'QSG_identifier' => 'personal-information-' . time(), 'QSG_desc' => '', 'QSG_order' => 1, 'QSG_show_group_name' => 1, 'QSG_show_group_desc' => 1, 'QSG_system' => EEM_Question_Group::system_personal, 'QSG_deleted' => 0);
                     break;
                 case 2:
                     $QSG_values = array('QSG_name' => __('Address Information', 'event_espresso'), 'QSG_identifier' => 'address-information-' . time(), 'QSG_desc' => '', 'QSG_order' => 2, 'QSG_show_group_name' => 1, 'QSG_show_group_desc' => 1, 'QSG_system' => EEM_Question_Group::system_address, 'QSG_deleted' => 0);
                     break;
             }
             // make sure we have some values before inserting them
             if (!empty($QSG_values)) {
                 // insert system question
                 $wpdb->insert($table_name, $QSG_values, array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d'));
                 $QSG_IDs[$QSG_system] = $wpdb->insert_id;
             }
         }
     }
     // QUESTIONS
     global $wpdb;
     $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
     $SQL = "SELECT QST_system FROM {$table_name} WHERE QST_system != ''";
     // what we have
     $questions = $wpdb->get_col($SQL);
     // what we should have
     $QST_systems = array('fname', 'lname', 'email', 'address', 'address2', 'city', 'state', 'country', 'zip', 'phone');
     $order_for_group_1 = 1;
     $order_for_group_2 = 1;
     // loop thru what we should have and compare to what we have
     foreach ($QST_systems as $QST_system) {
         // reset values array
         $QST_values = array();
         // if we don't have what we should have
         if (!in_array($QST_system, $questions)) {
             // add it
             switch ($QST_system) {
                 case 'fname':
                     $QST_values = array('QST_display_text' => __('First Name', 'event_espresso'), 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), 'QST_system' => 'fname', 'QST_type' => 'TEXT', 'QST_required' => 1, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 1, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'lname':
                     $QST_values = array('QST_display_text' => __('Last Name', 'event_espresso'), 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), 'QST_system' => 'lname', 'QST_type' => 'TEXT', 'QST_required' => 1, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 2, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'email':
                     $QST_values = array('QST_display_text' => __('Email Address', 'event_espresso'), 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), 'QST_system' => 'email', 'QST_type' => 'EMAIL', 'QST_required' => 1, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 3, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'address':
                     $QST_values = array('QST_display_text' => __('Address', 'event_espresso'), 'QST_admin_label' => __('Address - System Question', 'event_espresso'), 'QST_system' => 'address', 'QST_type' => 'TEXT', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 4, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'address2':
                     $QST_values = array('QST_display_text' => __('Address2', 'event_espresso'), 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), 'QST_system' => 'address2', 'QST_type' => 'TEXT', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 5, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'city':
                     $QST_values = array('QST_display_text' => __('City', 'event_espresso'), 'QST_admin_label' => __('City - System Question', 'event_espresso'), 'QST_system' => 'city', 'QST_type' => 'TEXT', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 6, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'state':
                     $QST_values = array('QST_display_text' => __('State/Province', 'event_espresso'), 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), 'QST_system' => 'state', 'QST_type' => 'STATE', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 7, 'QST_admin_only' => 0, 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'country':
                     $QST_values = array('QST_display_text' => __('Country', 'event_espresso'), 'QST_admin_label' => __('Country - System Question', 'event_espresso'), 'QST_system' => 'country', 'QST_type' => 'COUNTRY', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 8, 'QST_admin_only' => 0, 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'zip':
                     $QST_values = array('QST_display_text' => __('Zip/Postal Code', 'event_espresso'), 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), 'QST_system' => 'zip', 'QST_type' => 'TEXT', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 9, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
                 case 'phone':
                     $QST_values = array('QST_display_text' => __('Phone Number', 'event_espresso'), 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), 'QST_system' => 'phone', 'QST_type' => 'TEXT', 'QST_required' => 0, 'QST_required_text' => __('This field is required', 'event_espresso'), 'QST_order' => 10, 'QST_admin_only' => 0, 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), 'QST_wp_user' => self::get_default_creator_id(), 'QST_deleted' => 0);
                     break;
             }
             if (!empty($QST_values)) {
                 // insert system question
                 $wpdb->insert($table_name, $QST_values, array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d'));
                 $QST_ID = $wpdb->insert_id;
                 // QUESTION GROUP QUESTIONS
                 if (in_array($QST_system, array('fname', 'lname', 'email'))) {
                     $system_question_we_want = EEM_Question_Group::system_personal;
                 } else {
                     $system_question_we_want = EEM_Question_Group::system_address;
                 }
                 if (isset($QSG_IDs[$system_question_we_want])) {
                     $QSG_ID = $QSG_IDs[$system_question_we_want];
                 } else {
                     $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
                     if (is_array($id_col)) {
                         $QSG_ID = reset($id_col);
                     } else {
                         //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
                         EE_Log::instance()->log(__FILE__, __FUNCTION__, sprintf(__('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), $QST_ID), 'error');
                         continue;
                     }
                 }
                 // add system questions to groups
                 $wpdb->insert(EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order' => $QSG_ID === 1 ? $order_for_group_1++ : $order_for_group_2++), array('%d', '%d', '%d'));
             }
         }
     }
 }
 /**
  * Export a custom CSV of registration info including: A bunch of the reg fields, the time of the event, the price name,
  * and the questions associated with the registrations
  * @param type $event_id
  */
 function report_registrations_for_event()
 {
     $event_id = $this->_req_data['EVT_ID'];
     $reg_fields_to_include = array('REG_ID', 'REG_date', 'REG_code', 'REG_count', 'REG_final_price');
     $att_fields_to_include = array('ATT_fname', 'ATT_lname', 'ATT_email', 'ATT_address', 'ATT_address2', 'ATT_city', 'STA_ID', 'CNT_ISO', 'ATT_zip', 'ATT_phone');
     $registrations_csv_ready_array = array();
     $reg_model = EE_Registry::instance()->load_model('Registration');
     $registrations = $reg_model->get_all(array(array('EVT_ID' => $event_id), 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc')));
     //get all questions which relate to someone in this group
     $registration_ids = array_keys($registrations);
     //		EEM_Question::instance()->show_next_x_db_queries();
     $questions_for_these_registrations = EEM_Question::instance()->get_all(array(array('Answer.REG_ID' => array('IN', $registration_ids))));
     foreach ($registrations as $registration) {
         $reg_csv_array = array();
         /*@var $registration EE_Registration */
         foreach ($reg_fields_to_include as $field_name) {
             $field = $reg_model->field_settings_for($field_name);
             if ($field_name == 'REG_final_price') {
                 $value = $registration->get_pretty($field_name, 'localized_float');
             } else {
                 $value = $registration->get_pretty($field->get_name());
             }
             $reg_csv_array[$this->_get_column_name_for_field($field)] = $value;
             if ($field_name == 'REG_final_price') {
                 //add a column named Currency after the final price
                 $reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code;
             }
         }
         //get pretty status
         $reg_csv_array[__("Registration Status", 'event_espresso')] = $registration->pretty_status();
         //get pretty trnasaction status
         $reg_csv_array[__("Transaction Status", 'event_espresso')] = $registration->transaction()->pretty_status();
         //get whether or not the user has checked in
         $reg_csv_array[__("Check-Ins", "event_espresso")] = $registration->count_checkins();
         //get ticket of registration and its price
         $ticket_model = EE_Registry::instance()->load_model('Ticket');
         $ticket = $registration->ticket();
         $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket->name();
         //get datetime(s) of registration
         $datetimes_strings = array();
         foreach ($ticket->datetimes() as $datetime) {
             $datetimes_strings[] = $datetime->start_date_and_time();
         }
         $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
         //add attendee columns
         $attendee = $registration->attendee();
         foreach ($att_fields_to_include as $att_field_name) {
             if ($attendee) {
                 if ($att_field_name == 'STA_ID') {
                     $state = $attendee->state_obj();
                     if ($state) {
                         $value = $state->name();
                     } else {
                         $value = '';
                     }
                 } elseif ($att_field_name == 'CNT_ISO') {
                     $country = $attendee->country_obj();
                     if ($country) {
                         $value = $country->name();
                     } else {
                         $value = '';
                     }
                 } else {
                     $value = $attendee->get_pretty($att_field_name);
                 }
             } else {
                 $value = '';
             }
             $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
             $reg_csv_array[$this->_get_column_name_for_field($field_obj)] = $value;
         }
         //make sure each registration has the same questions in the same order
         foreach ($questions_for_these_registrations as $question) {
             if (!isset($reg_csv_array[$question->admin_label()])) {
                 $reg_csv_array[$question->admin_label()] = null;
             }
         }
         //now fill out the questions THEY answered
         foreach ($registration->answers() as $answer) {
             /* @var $answer EE_Answer */
             $reg_csv_array[$answer->question()->admin_label()] = $answer->pretty_value();
         }
         $registrations_csv_ready_array[] = $reg_csv_array;
     }
     //if we couldn't export anything, we want to at least show the column headers
     if (empty($registrations_csv_ready_array)) {
         $reg_csv_array = array();
         foreach ($reg_fields_to_include as $model_name => $field_list) {
             $model = EE_Registry::instance()->load_model($model_name);
             foreach ($field_list as $field_name) {
                 $field = $model->field_settings_for($field_name);
                 $reg_csv_array[$this->_get_column_name_for_field($field)] = null;
                 //$registration->get($field->get_name());
             }
         }
         $registrations_csv_ready_array[] = $reg_csv_array;
     }
     $event = EEM_Event::instance()->get_one_by_ID($event_id);
     $filename = sprintf("registrations-for-%s", $event->slug());
     $handle = $this->EE_CSV->begin_sending_csv($filename);
     $this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array);
     $this->EE_CSV->end_sending_csv($handle);
 }
?>
</span></p>
            <div>
                <ul class="question-list-sortable">
                    <?php 
$question_order = 0;
$question_group_questions = $question_group->questions();
foreach ($all_questions as $question_ID => $question) {
    if ($question instanceof EE_Question) {
        /*@var $question EE_Question*/
        $checked = isset($question_group_questions[$question_ID]) ? ' checked="checked"' : '';
        // disable questions from the personal information question group
        // is it required in the current question group? if so don't allow admins to remove it
        $disabled = in_array($question->system_ID(), EEM_Question::instance()->required_system_questions_in_system_question_group($QSG_system)) ? 'disabled="disabled"' : '';
        //limit where system questions can appear
        if ($question->system_ID() && !in_array($question->system_ID(), EEM_Question::instance()->allowed_system_questions_in_system_question_group($QSG_system))) {
            continue;
            //skip over system question not assigned to this group except for the address system group cause we want the address questions to display even if they aren't selected (but still not show the personal system questions).  The third condition checks if we're displaying a non system question group and the question is a system question, then we skip because for non-system question groups we only want to show non-system questions.
        }
        ?>
                    <li class="ee-question-sortable">
                        <label for="question-<?php 
        echo $question_ID;
        ?>
">
                            <input type="checkbox" name="questions[<?php 
        echo $question_ID;
        ?>
]" id="question-<?php 
        echo $question_ID;
        ?>
 /**
  * Creates a form input from this question which can be used in HTML forms
  * @param EE_Registration $registration
  * @param EE_Answer $answer
  * @param array $input_constructor_args
  * @return EE_Form_Input_Base
  */
 public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array())
 {
     $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
     $input_constructor_args = array_merge(array('required' => $this->required() ? true : false, 'html_label_text' => $this->display_text(), 'required_validation_error_message' => $this->required_text()), $input_constructor_args);
     if (!$answer instanceof EE_Answer && $registration instanceof EE_Registration) {
         $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
     }
     // has this question been answered ?
     if ($answer instanceof EE_Answer) {
         //answer gets htmlspecialchars called on it, undo that please
         //because the form input's display strategy may call esc_attr too
         //which also does html special characters
         $values_with_html_special_chars = $answer->value();
         if (is_array($values_with_html_special_chars)) {
             $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
         } else {
             $default_value = htmlspecialchars_decode($values_with_html_special_chars);
         }
         $input_constructor_args['default'] = $default_value;
     }
     $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
     if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) {
         $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(null, min($max_max_for_question, $this->max()));
     }
     $input_constructor_args = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', $input_constructor_args, $registration, $this, $answer);
     $result = null;
     switch ($this->type()) {
         // Text
         case EEM_Question::QST_type_text:
             $result = new EE_Text_Input($input_constructor_args);
             break;
             // Textarea
         // Textarea
         case EEM_Question::QST_type_textarea:
             $result = new EE_Text_Area_Input($input_constructor_args);
             break;
             // Radio Buttons
         // Radio Buttons
         case EEM_Question::QST_type_radio:
             $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
             break;
             // Dropdown
         // Dropdown
         case EEM_Question::QST_type_dropdown:
             $result = new EE_Select_Input($this->options(), $input_constructor_args);
             break;
             // State Dropdown
         // State Dropdown
         case EEM_Question::QST_type_state:
             $state_options = apply_filters('FHEE__EE_Question__generate_form_input__state_options', null, $this, $registration, $answer);
             $result = new EE_State_Select_Input($state_options, $input_constructor_args);
             break;
             // Country Dropdown
         // Country Dropdown
         case EEM_Question::QST_type_country:
             $country_options = apply_filters('FHEE__EE_Question__generate_form_input__country_options', null, $this, $registration, $answer);
             $result = new EE_Country_Select_Input($country_options, $input_constructor_args);
             break;
             // Checkboxes
         // Checkboxes
         case EEM_Question::QST_type_checkbox:
             $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
             break;
             // Date
         // Date
         case EEM_Question::QST_type_date:
             $result = new EE_Datepicker_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_html_textarea:
             $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
             $result = new EE_Text_Area_Input($input_constructor_args);
             $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
             break;
         case EEM_Question::QST_type_email:
             $result = new EE_Email_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_us_phone:
             $result = new EE_Phone_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_int:
             $input_constructor_args['validation_strategies'][] = new EE_Int_Validation_Strategy();
             $result = new EE_Text_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_decimal:
             $input_constructor_args['validation_strategies'][] = new EE_Float_Validation_Strategy();
             $result = new EE_Text_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_url:
             $input_constructor_args['validation_strategies'][] = new EE_URL_Validation_Strategy();
             $result = new EE_Text_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_year:
             $result = new EE_Year_Input($input_constructor_args, apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this), apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this), apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this));
             break;
         case EEM_Question::QST_type_multi_select:
             $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
             break;
             // fallback
         // fallback
         default:
             $default_input = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', null, $this->type(), $this, $input_constructor_args);
             if (!$default_input) {
                 $default_input = new EE_Text_Input($input_constructor_args);
             }
             $result = $default_input;
     }
     return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
 }
 /**
  * Gets the registration's answer value to the specified question
  * (either the question's ID or a question object)
  * @param EE_Question|int $question
  * @param bool            $pretty_value
  * @return array|string if pretty_value= true, the result will always be a string
  * (because the answer might be an array of answer values, so passing pretty_value=true
  * will convert it into some kind of string)
  */
 public function answer_value_to_question($question, $pretty_value = true)
 {
     $question_id = EEM_Question::instance()->ensure_is_ID($question);
     return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
 }
 /**
  * Gets the string answer to the question for this registration's attendee
  * @param EE_Registration $registration
  * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
  *	Passing in the QST_system value is more efficient
  * @param boolean $pretty_answer
  * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for 
  * a question corresponding to an attendee field, returns null)
  */
 public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE)
 {
     $field_name = NULL;
     $value = NULL;
     //backward compat: we still want to find the question's ID
     if (is_numeric($question_system_id)) {
         //find this question's QST_system value
         $question_id = $question_system_id;
         $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system');
     } else {
         $question_id = intval(EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID'));
     }
     //only bother checking if the registration has an attendee
     if ($registration->attendee() instanceof EE_Attendee) {
         $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
         if ($field_name) {
             if ($pretty_answer) {
                 if ($field_name == 'STA_ID') {
                     $state = $registration->attendee()->state_obj();
                     $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
                 } else {
                     if ($field_name == 'CNT_ISO') {
                         $country = $registration->attendee()->country_obj();
                         $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
                     } else {
                         $value = $registration->attendee()->get_pretty($field_name);
                     }
                 }
                 //if field name is blank, leave the value as null too
             } else {
                 $value = $registration->attendee()->get($field_name);
             }
         }
         //if no field was found, leave value blank
     }
     return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
 }
 public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE)
 {
     $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
     if ($count) {
         //note: this a subclass of EEM_Soft_Delete_Base, so thsi is actually only getting nontrashed items
         $where = isset($query_params[0]) ? array($query_params[0]) : array();
         $results = $this->_question_model->count_deleted($where);
     } else {
         //note: this a subclass of EEM_Soft_Delete_Base, so thsi is actually only getting nontrashed items
         $results = $this->_question_model->get_all_deleted($query_params);
     }
     return $results;
 }
 /**
  * Export a custom CSV of registration info including: A bunch of the reg fields, the time of the event, the price name,
  * and the questions associated with the registrations
  * @param int $event_id
  */
 function report_registrations_for_event($event_id = NULL)
 {
     $reg_fields_to_include = array('TXN_ID', 'ATT_ID', 'REG_ID', 'REG_date', 'REG_code', 'REG_count', 'REG_final_price');
     $att_fields_to_include = array('ATT_fname', 'ATT_lname', 'ATT_email', 'ATT_address', 'ATT_address2', 'ATT_city', 'STA_ID', 'CNT_ISO', 'ATT_zip', 'ATT_phone');
     $registrations_csv_ready_array = array();
     $reg_model = EE_Registry::instance()->load_model('Registration');
     $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(array('OR' => array('Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)), 'STS_ID' => EEM_Registration::status_id_approved), 'Ticket.TKT_deleted' => array('IN', array(true, false))), 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), 'force_join' => array('Transaction', 'Ticket', 'Attendee'), 'caps' => EEM_Base::caps_read_admin), $event_id);
     if ($event_id) {
         $query_params[0]['EVT_ID'] = $event_id;
     } else {
         $query_params['force_join'][] = 'Event';
     }
     $registration_rows = $reg_model->get_all_wpdb_results($query_params);
     //get all questions which relate to someone in this group
     $registration_ids = array();
     foreach ($registration_rows as $reg_row) {
         $registration_ids[] = intval($reg_row['Registration.REG_ID']);
     }
     //		EEM_Question::instance()->show_next_x_db_queries();
     $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID' => array('IN', $registration_ids))));
     foreach ($registration_rows as $reg_row) {
         if (is_array($reg_row)) {
             $reg_csv_array = array();
             if (!$event_id) {
                 //get the event's name and Id
                 $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
             }
             $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
             /*@var $reg_row EE_Registration */
             foreach ($reg_fields_to_include as $field_name) {
                 $field = $reg_model->field_settings_for($field_name);
                 if ($field_name == 'REG_final_price') {
                     $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
                 } elseif ($field_name == 'REG_count') {
                     $value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
                 } elseif ($field_name == 'REG_date') {
                     $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
                 } else {
                     $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
                 }
                 $reg_csv_array[$this->_get_column_name_for_field($field)] = $value;
                 if ($field_name == 'REG_final_price') {
                     //add a column named Currency after the final price
                     $reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code;
                 }
             }
             //get pretty status
             $stati = EEM_Status::instance()->localized_status(array($reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso')), FALSE, 'sentence');
             $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
             //get pretty trnasaction status
             $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
             $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
             $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
             $payment_methods = array();
             $gateway_txn_ids_etc = array();
             $payment_times = array();
             if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
                 $payments_info = EEM_Payment::instance()->get_all_wpdb_results(array(array('TXN_ID' => $reg_row['TransactionTable.TXN_ID'], 'STS_ID' => EEM_Payment::status_id_approved), 'force_join' => array('Payment_Method')), ARRAY_A, 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
                 foreach ($payments_info as $payment_method_and_gateway_txn_id) {
                     $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
                     $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
                     $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
                 }
             }
             $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
             $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
             $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
             //get whether or not the user has checked in
             $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
             //get ticket of registration and its price
             $ticket_model = EE_Registry::instance()->load_model('Ticket');
             if ($reg_row['Ticket.TKT_ID']) {
                 $ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
                 $datetimes_strings = array();
                 foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
                     $datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
                 }
             } else {
                 $ticket_name = __('Unknown', 'event_espresso');
                 $datetimes_strings = array(__('Unknown', 'event_espresso'));
             }
             $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
             $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
             //get datetime(s) of registration
             //add attendee columns
             foreach ($att_fields_to_include as $att_field_name) {
                 $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
                 if ($reg_row['Attendee_CPT.ID']) {
                     if ($att_field_name == 'STA_ID') {
                         $value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
                     } elseif ($att_field_name == 'CNT_ISO') {
                         $value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
                     } else {
                         $value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
                     }
                 } else {
                     $value = '';
                 }
                 $reg_csv_array[$this->_get_column_name_for_field($field_obj)] = $value;
             }
             //make sure each registration has the same questions in the same order
             foreach ($questions_for_these_regs_rows as $question_row) {
                 if (!isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
                     $reg_csv_array[$question_row['Question.QST_admin_label']] = null;
                 }
             }
             //now fill out the questions THEY answered
             foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) {
                 /* @var $answer EE_Answer */
                 if ($answer_row['Question.QST_ID']) {
                     $question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']);
                 } else {
                     $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
                 }
                 if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) {
                     $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']);
                 } else {
                     $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']);
                 }
             }
             $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row);
         }
     }
     //if we couldn't export anything, we want to at least show the column headers
     if (empty($registrations_csv_ready_array)) {
         $reg_csv_array = array();
         $model_and_fields_to_include = array('Registration' => $reg_fields_to_include, 'Attendee' => $att_fields_to_include);
         foreach ($model_and_fields_to_include as $model_name => $field_list) {
             $model = EE_Registry::instance()->load_model($model_name);
             foreach ($field_list as $field_name) {
                 $field = $model->field_settings_for($field_name);
                 $reg_csv_array[$this->_get_column_name_for_field($field)] = null;
                 //$registration->get($field->get_name());
             }
         }
         $registrations_csv_ready_array[] = $reg_csv_array;
     }
     if ($event_id) {
         $event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
         if (!$event_slug) {
             $event_slug = __('unknown', 'event_espresso');
         }
     } else {
         $event_slug = __('all', 'event_espresso');
     }
     $filename = sprintf("registrations-for-%s", $event_slug);
     $handle = $this->EE_CSV->begin_sending_csv($filename);
     $this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array);
     $this->EE_CSV->end_sending_csv($handle);
 }
 /**
  * @param EE_Registration $registration
  * @param EE_Question     $question
  * @param mixed EE_Answer|NULL      $answer
  * @return EE_Form_Input_Base
  */
 private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
 {
     //		d( $registration );
     //		d( $question );
     //		d( $answer );
     // array of params to pass to parent constructor.
     // possible values:
     //		html_id;
     //		html_class;
     //		html_style;
     //		name;
     //		html_name;
     //		html_label_id;
     //		html_label_class;
     //		html_label_style;
     //		html_label_text;
     //		html_label;
     //		html_help_text;
     //		html_help_class = 'description';
     //		html_help_style;
     //		raw_value;
     $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
     $input_constructor_args = array('html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, 'required' => $question->required() ? TRUE : FALSE, 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, 'html_label_class' => 'ee-reg-qstn', 'html_label_text' => $question->display_text(), 'required_validation_error_message' => $question->required_text());
     // has this question been answered ?
     if ($answer instanceof EE_Answer) {
         if ($answer->ID()) {
             $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
             $input_constructor_args['html_id'] .= '-' . $answer->ID();
             $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
         }
         $input_constructor_args['default'] = $answer->value();
     }
     //add "-lbl" to the end of the label id
     $input_constructor_args['html_label_id'] .= '-lbl';
     $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID());
     if (EEM_Question::instance()->question_type_is_in_category($question->type(), 'text')) {
         $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(null, min($max_max_for_question, $question->max()));
     }
     $input_constructor_args = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', $input_constructor_args, $registration, $question, $answer);
     $this->_required_questions[$identifier] = $question->required() ? true : false;
     switch ($question->type()) {
         // Text
         case EEM_Question::QST_type_text:
             if ($identifier == 'email') {
                 return new EE_Email_Input($input_constructor_args);
             } else {
                 return new EE_Text_Input($input_constructor_args);
             }
             break;
             // Textarea
         // Textarea
         case EEM_Question::QST_type_textarea:
             return new EE_Text_Area_Input($input_constructor_args);
             break;
             // Radio Buttons
         // Radio Buttons
         case EEM_Question::QST_type_radio:
             return new EE_Radio_Button_Input($question->options(), $input_constructor_args);
             break;
             // Dropdown
         // Dropdown
         case EEM_Question::QST_type_dropdown:
             return new EE_Select_Input($question->options(), $input_constructor_args);
             break;
             // State Dropdown
         // State Dropdown
         case EEM_Question::QST_type_state:
             $state_options = array('' => array('' => ''));
             $states = $this->checkout->action == 'process_reg_step' ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_active_states();
             if (!empty($states)) {
                 foreach ($states as $state) {
                     if ($state instanceof EE_State) {
                         $state_options[$state->country()->name()][$state->ID()] = $state->name();
                     }
                 }
             }
             $state_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', $state_options, $this, $registration, $question, $answer);
             return new EE_State_Select_Input($state_options, $input_constructor_args);
             break;
             // Country Dropdown
         // Country Dropdown
         case EEM_Question::QST_type_country:
             $country_options = array('' => '');
             // get possibly cached list of countries
             $countries = $this->checkout->action == 'process_reg_step' ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries();
             if (!empty($countries)) {
                 foreach ($countries as $country) {
                     if ($country instanceof EE_Country) {
                         $country_options[$country->ID()] = $country->name();
                     }
                 }
             }
             $country_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', $country_options, $this, $registration, $question, $answer);
             return new EE_Country_Select_Input($country_options, $input_constructor_args);
             break;
             // Checkboxes
         // Checkboxes
         case EEM_Question::QST_type_checkbox:
             return new EE_Checkbox_Multi_Input($question->options(), $input_constructor_args);
             break;
             // Date
         // Date
         case EEM_Question::QST_type_date:
             return new EE_Datepicker_Input($input_constructor_args);
             break;
         case EEM_Question::QST_type_html_textarea:
             $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
             $input = new EE_Text_Area_Input($input_constructor_args);
             $input->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
             return $input;
             // fallback
         // fallback
         default:
             $default_input = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', null, $question->type(), $question, $input_constructor_args);
             if (!$default_input) {
                 $default_input = new EE_Text_Input($input_constructor_args);
             }
             return $default_input;
     }
 }