/**
  * Callback for the AHEE__EE_Config___load_core_config__end hook.
  * basically just calls EE_Config->get_config() which will take care of loading or creating our config object for us
  *
  * @since    4.3.0
  * @throws EE_Error
  * @param \EE_Config $EE_Config
  * @return \StdClass
  */
 public static function set_config(EE_Config $EE_Config)
 {
     foreach (self::$_ee_config_registry as $config_class => $settings) {
         //first some validation of our incoming class_name.  We'll throw an error early if its' not registered correctly
         if (!class_exists($config_class)) {
             throw new EE_Error(sprintf(__('The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class', 'event_espresso'), $config_class));
         }
         $EE_Config->get_config($settings['section'], $settings['name'], $config_class);
     }
 }
 function _migration_step($num_items = 50)
 {
     //get teh calendar's config
     if (isset(EE_Config::instance()->addons->EE_Calendar) && EE_Config::instance()->addons->EE_Calendar instanceof EE_Calendar_Config) {
         $c = EE_Config::instance()->addons->EE_Calendar;
     } else {
         $c = new EE_Calendar_Config();
         EE_Config::instance()->addons->EE_Calendar = $c;
     }
     $items_actually_migrated = 0;
     $old_org_options = get_option('espresso_calendar_options');
     //the option's name differened depending on the version of the calendar
     if (!$old_org_options) {
         $old_org_options = get_option('espresso_calendar_settings');
     }
     foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
         //only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
         if (isset($old_org_options[$option_name])) {
             $this->_handle_org_option($option_name, $old_org_options[$option_name], $c);
         }
         $items_actually_migrated++;
     }
     //		d($c);
     $success = EE_Config::instance()->update_config('addons', 'EE_Calendar', $c);
     if (!$success) {
         $this->add_error(EE_Error::get_notices());
     }
     //		d($success);
     //		d($c);
     //		die;
     if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
         $this->set_completed();
     }
     return $items_actually_migrated;
 }
 /**
  *    set_hooks - for hooking into EE Core, other modules, etc
  *
  * @access    public
  * @return    void
  */
 public static function set_hooks()
 {
     EED_Multi_Event_Registration::set_definitions();
     add_action('wp_enqueue_scripts', array('EED_Multi_Event_Registration', 'enqueue_styles_and_scripts'), 10);
     EE_Config::register_route('view', 'Multi_Event_Registration', 'view_event_cart', 'event_cart');
     EE_Config::register_route('update', 'Multi_Event_Registration', 'update_event_cart', 'event_cart');
     EE_Config::register_route('add_ticket', 'Multi_Event_Registration', 'add_ticket', 'event_cart');
     EE_Config::register_route('remove_ticket', 'Multi_Event_Registration', 'remove_ticket', 'event_cart');
     EE_Config::register_route('delete_ticket', 'Multi_Event_Registration', 'delete_ticket', 'event_cart');
     EE_Config::register_route('empty', 'Multi_Event_Registration', 'empty_event_cart', 'event_cart');
     // don't empty cart
     add_filter('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', '__return_false');
     // process registration links
     add_filter('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', array('EED_Multi_Event_Registration', 'filter_ticket_selector_form_html'), 10, 2);
     add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', array('EED_Multi_Event_Registration', 'filter_ticket_selector_submit_button'), 10, 2);
     add_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', array('EED_Multi_Event_Registration', 'style_sheet_URLs'), 10, 1);
     add_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', array('EED_Multi_Event_Registration', 'javascript_URLs'), 10, 1);
     add_filter('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', array('EED_Multi_Event_Registration', 'filter_ticket_selector_redirect_url'), 10, 2);
     // verify that SPCO registrations correspond to tickets in cart
     add_filter('FHEE__EED_Single_Page_Checkout___initialize__checkout', array('EED_Multi_Event_Registration', 'verify_tickets_in_cart'), 10, 1);
     // redirect to event_cart
     add_action('EED_Ticket_Selector__process_ticket_selections__before', array('EED_Multi_Event_Registration', 'redirect_to_event_cart'), 10);
     add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', array('EED_Multi_Event_Registration', 'return_to_event_cart_button'), 10, 2);
     // toggling reg status
     add_filter('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', array('EED_Multi_Event_Registration', 'toggle_registration_status_if_no_monies_owing'), 10, 2);
     // display errors
     add_action('wp_footer', array('EED_Multi_Event_Registration', 'cart_results_modal_div'), 1);
     // update cart in session
     add_action('shutdown', array('EED_Multi_Event_Registration', 'save_cart'), 10);
 }
 /**
  * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
  * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
  * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
  * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
  * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
  * @param int $num_items_to_migrate
  * @return int number of items ACTUALLY migrated
  */
 protected function _migration_step($num_items_to_migrate = 50)
 {
     $items_actually_migrated = 0;
     $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate);
     foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) {
         if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) {
             if (!$old_gateway_settings) {
                 //no settings existed for this gateway anyways... weird...
                 $items_actually_migrated++;
                 continue;
             }
             //now prepare the settings to make sure they're in the 4.1 format
             $success = $this->_convert_gateway_settings($old_gateway_slug, $old_gateway_settings, isset(EE_Config::instance()->gateway->active_gateways[$old_gateway_slug]));
             if ($success) {
                 EE_Config::instance()->gateway->payment_settings[$old_gateway_slug] = 'Deprecated';
             }
         }
         $items_actually_migrated++;
     }
     EE_Config::instance()->update_espresso_config(false, false);
     if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
         $this->set_completed();
     }
     return $items_actually_migrated;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->config_path = EE_APPPATH . '/config/config' . EXT;
     $this->database_path = EE_APPPATH . '/config/database' . EXT;
     $this->_initialize();
 }
 /**
  * 	set_hooks - for hooking into EE Core, other modules, etc
  *
  *  @access 	public
  *  @return 	void
  */
 public static function set_hooks()
 {
     // create download buttons
     add_filter('FHEE__espresso_list_of_event_dates__datetime_html', array('EED_Ical', 'generate_add_to_iCal_button'), 10, 2);
     // process ics download request
     EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file');
 }
 protected function _migrate_old_row($old_row)
 {
     $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
     global $wpdb;
     $wpdb->query($wpdb->prepare("UPDATE " . $this->_old_table . " SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
     $slug = $old_row['post_name'];
     $matches = array();
     $success = preg_match_all('(ESPRESSO_[^ \\]]*)', $new_post_content, $matches);
     if ($success) {
         $shortcodes = $matches[0];
         foreach ($shortcodes as $shortcode) {
             EE_Config::instance()->core->post_shortcodes[$slug][$shortcode] = $old_row['ID'];
             EE_Config::instance()->core->post_shortcodes['posts'][$shortcode] = $old_row['ID'];
         }
         //		$start_of_ee_shortcode = strpos($new_post_content,"[ESPRESSO_");
         //		if( $start_of_ee_shortcode !== FALSE){
         //			$closing_bracket = strpos($new_post_content,"]",$start_of_ee_shortcode);
         //			$shortcode = substr($new_post_content, $start_of_ee_shortcode+1,$closing_bracket-2);//grab the shortcode minus brackets
         //
         //			EE_Config::instance()->core->post_shortcodes[$slug][$shortcode] = $old_row['ID'];
         //			EE_Config::instance()->core->post_shortcodes['posts'][$shortcode] = $old_row['ID'];
         //			EE_Config::instance()->update_espresso_config();
         //		}
     }
 }
 /**
  * @param string $value_to_normalize
  * @return float
  * @throws \EE_Validation_Error
  */
 public function normalize($value_to_normalize)
 {
     if ($value_to_normalize === NULL) {
         return 0.0;
     }
     $normalized_value = '';
     if (is_string($value_to_normalize)) {
         $normalized_value = str_replace(array(" ", EE_Config::instance()->currency->thsnds), "", $value_to_normalize);
         //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
         $normalized_value = str_replace(EE_Config::instance()->currency->dec_mrk, ".", $normalized_value);
         //double-check there's absolutely nothing left on this string besides numbers
         $normalized_value = preg_replace("/[^0-9,. ]/", "", $normalized_value);
     }
     if (strlen($value_to_normalize) > strlen($normalized_value)) {
         //find if this input has a float validation strategy
         //in which case, use its message
         $validation_error_message = NULL;
         foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
             if ($validation_strategy instanceof EE_Float_Validation_Strategy) {
                 $validation_error_message = $validation_strategy->get_validation_error_message();
             }
         }
         //this really shouldn't ever happen because fields with a float normalization strategy
         //should also have a float validation strategy, but in case it doesnt use the default
         if (!$validation_error_message) {
             $default_validation_strategy = new EE_Float_Validation_Strategy();
             $validation_error_message = $default_validation_strategy->get_validation_error_message();
         }
         throw new EE_Validation_Error($validation_error_message, 'float_only');
     } else {
         return floatval($normalized_value);
     }
 }
 /**
  * @param string $value_to_normalize
  * @return int|mixed|string
  * @throws \EE_Validation_Error
  */
 public function normalize($value_to_normalize)
 {
     if (is_int($value_to_normalize)) {
         return $value_to_normalize;
     }
     if (!is_string($value_to_normalize)) {
         throw new EE_Validation_Error(sprintf(__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), print_r($value_to_normalize, TRUE), gettype($value_to_normalize)));
     }
     $thousands_separator = EE_Config::instance()->currency->thsnds;
     $value_to_normalize = str_replace($thousands_separator, "", $value_to_normalize);
     $value_to_normalize = str_replace(array(" ", "\t"), '', $value_to_normalize);
     if (preg_match('/^\\d+$/', $value_to_normalize)) {
         return intval($value_to_normalize);
     } else {
         //find if this input has a int validation strategy
         //in which case, use its message
         $validation_error_message = NULL;
         foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
             if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
                 $validation_error_message = $validation_strategy->get_validation_error_message();
             }
         }
         //this really shouldn't ever happen because fields with a int normalization strategy
         //should also have a int validation strategy, but in case it doesnt use the default
         if (!$validation_error_message) {
             $default_validation_strategy = new EE_Int_Validation_Strategy();
             $validation_error_message = $default_validation_strategy->get_validation_error_message();
         }
         throw new EE_Validation_Error($validation_error_message, 'numeric_only');
     }
 }
 /**
  * Gets the form for all the settings related to this payment method type
  * @return EE_Payment_Method_Form
  */
 public function generate_new_settings_form()
 {
     $pdf_payee_input_name = 'pdf_payee_name';
     $confirmation_text_input_name = 'page_confirmation_text';
     $form = new EE_Payment_Method_Form(array('extra_meta_inputs' => array($pdf_payee_input_name => new EE_Text_Input(array('html_label_text' => sprintf(__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link()))), 'pdf_payee_email' => new EE_Email_Input(array('html_label_text' => sprintf(__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()))), 'pdf_payee_tax_number' => new EE_Text_Input(array('html_label_text' => sprintf(__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()))), 'pdf_payee_address' => new EE_Text_Area_Input(array('html_label_text' => sprintf(__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()), 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()))), 'pdf_instructions' => new EE_Text_Area_Input(array('html_label_text' => sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), 'default' => __("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'), 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()))), 'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array('html_label_text' => sprintf(__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()), 'default' => EE_Config::instance()->organization->logo_url, 'html_help_text' => __("(Logo for the top left of the invoice)", 'event_espresso'))), $confirmation_text_input_name => new EE_Text_Area_Input(array('html_label_text' => sprintf(__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()), 'default' => __("Payment must be received within 48 hours of event date.  Details about where to send payment is included on the invoice.", 'event_espresso'), 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()))), 'page_extra_info' => new EE_Text_Area_Input(array('html_label_text' => sprintf(__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()), 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy())))), 'include' => array('PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order', $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image', $confirmation_text_input_name, 'page_extra_info')));
     $form->add_subsections(array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')), $pdf_payee_input_name);
     $form->add_subsections(array('header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')), $confirmation_text_input_name);
     return $form;
 }
 /**
  * @param \WP_REST_Request $request
  * @return \EE_Config|\WP_Error
  */
 public static function handle_request(\WP_REST_Request $request)
 {
     $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap();
     if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) {
         return \EE_Config::instance();
     } else {
         return new \WP_Error('cannot_read_config', sprintf(__('You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', 'event_espresso'), $cap), array('status' => 403));
     }
 }
 /**
  * 	set_hooks - for hooking into EE Core, other modules, etc
  *
  *  @access 	public
  *  @return 	void
  */
 public static function set_hooks()
 {
     if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && EE_Registry::instance()->CFG->registration->use_bot_trap) {
         define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
         add_action('AHEE__ticket_selector_chart__template__after_ticket_selector', array('EED_Bot_Trap', 'generate_bot_trap'), 10, 2);
         add_action('EED_Ticket_Selector__process_ticket_selections__before', array('EED_Bot_Trap', 'process_bot_trap'), 1, 2);
         // redirect bots to bogus success page
         EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
     }
 }
    /**
     * Checks that there is at least one active gateway. If not, add a notice
     */
    public function check_payment_gateway_setup()
    {
        $actives = EE_Config::instance()->gateway->active_gateways;
        if (!$actives || count($actives) < 1) {
            $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL);
            echo '<div class="error">
				 <p>' . sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='{$url}'>", "</a>") . '</p>
			 </div>';
        }
    }
 /**
  * 	set_hooks - for hooking into EE Core, other modules, etc
  *
  *  @access 	public
  *  @return 	void
  */
 public static function set_hooks()
 {
     // routing
     EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
     add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
     add_action('AHEE_event_details_before_post', array('EED_Ticket_Selector', 'ticket_selector_form_open'), 10, 1);
     add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
     add_action('AHEE__ticket_selector_chart__template__after_ticket_selector', array('EED_Ticket_Selector', 'display_ticket_selector_submit'), 10, 1);
     add_action('AHEE_event_details_after_post', array('EED_Ticket_Selector', 'ticket_selector_form_close'), 10);
     add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
 }
 public function __construct($url_link = 0)
 {
     if ($this->registration = EE_Registry::instance()->load_model('Registration')->get_registration_for_reg_url_link($url_link)) {
         $this->transaction = $this->registration->transaction();
         $payment_settings = EE_Config::instance()->gateway->payment_settings;
         //get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
         $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
     } else {
         EE_Error::add_error(__('Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
 }
 /**
  * 	set_hooks - for hooking into EE Core, other modules, etc
  *
  *  @access 	public
  *  @return 	void
  */
 public static function set_hooks()
 {
     EE_Config::register_route('promotions', 'EED_Promotions', 'run');
     add_action('wp_enqueue_scripts', array('EED_Promotions', 'translate_js_strings'), 1);
     add_action('wp_enqueue_scripts', array('EED_Promotions', 'enqueue_scripts'));
     add_action('AHEE__ticket_selector_chart__template__before_ticket_selector', array('EED_Promotions', 'display_event_promotions_banner'), 10, 1);
     add_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', array('EED_Promotions', 'auto_process_promotions_in_cart'), 10, 1);
     add_action('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', array('EED_Promotions', 'add_promotions_form_inputs'));
     // adjust SPCO
     add_filter('FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', array('EED_Promotions', 'adjust_SPCO_line_item_display'), 10, 2);
 }
 /**
  * 	set_hooks - for hooking into EE Core, other modules, etc
  *
  *  @access 	public
  *  @return 	void
  */
 public static function set_hooks()
 {
     EED_Single_Page_Checkout::set_definitions();
     add_filter('FHEE_load_EE_messages', '__return_true');
     // configure the reg steps array
     EED_Single_Page_Checkout::setup_reg_steps_array();
     // set routing
     EE_Config::register_route('_register', 'EED_Single_Page_Checkout', 'run');
     foreach (self::$_reg_steps as $reg_step => $reg_step_details) {
         EE_Config::register_route($reg_step, 'EED_Single_Page_Checkout', $reg_step_details['process_func']);
     }
     //EE_Config::register_route( 'finalize_registration', 'EED_Single_Page_Checkout', 'finalize_registration' );
     // add powered by EE msg
     add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
 }
示例#18
0
 /**
  * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. 
  * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
  * Returns a float
  * @param type $value_inputted_for_field_on_model_object
  * @return float
  */
 function prepare_for_set($value_inputted_for_field_on_model_object)
 {
     //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
     //remove whitespaces and thousands separators
     if (is_string($value_inputted_for_field_on_model_object)) {
         $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), "", $value_inputted_for_field_on_model_object);
         //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
         //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
         $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", $value_inputted_for_field_on_model_object);
         //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
         //double-check there's absolutely nothing left on this string besides numbers
         $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
     }
     //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
     return floatval($value_inputted_for_field_on_model_object);
 }
 /**
  *	_migration_step
  *
  * @access protected
  * @param int $num_items
  * @throws EE_Error
  * @return int number of items ACTUALLY migrated
  */
 protected function _migration_step($num_items = 1)
 {
     // if this isn't set then something is really wrong
     if (!EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
         throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
     }
     $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : NULL;
     if (!$invoice_settings) {
         $this->add_error(__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
     } else {
         $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
         $invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
         $invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
         $invoice_settings['template_invoice_email'] = '';
         $invoice_settings['template_invoice_tax_number'] = '';
         unset($invoice_settings['pdf_instructions']);
         unset($invoice_settings['payable_to']);
         unset($invoice_settings['payment_address']);
         EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
         EE_Config::instance()->update_espresso_config(false, false);
         //@todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
         //(why is it tough to change? because we want to update the receipt and invoice message template, but
         //message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
         //update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
         //also we don't want to build a dependency on the messages code because it is likely to change soon
         if (!in_array($invoice_settings['invoice_css'], array('', 'simple.css'))) {
             EE_Error::add_persistent_admin_notice('invoice_css_not_updated', sprintf(__('You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.', 'event_espresso'), $invoice_settings['invoice_css']), FALSE);
         }
         EE_Registry::instance()->load_helper('Template');
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
         $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE);
         $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE);
         if ($overridden_invoice_body || $overridden_receipt_body) {
             EE_Error::add_persistent_admin_notice('invoice_overriding_templates', sprintf(__('Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overriden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.')), TRUE);
         }
     }
     //regardless of whether it worked or not, we ought to continue the migration
     $this->set_completed();
     return 1;
 }
 /**
  * 	set_hooks - for hooking into EE Core, other modules, etc
  *
  *  @access 	public
  *  @return 	void
  */
 public static function set_hooks()
 {
     EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run');
     EE_Config::register_route('event_list', 'Events_Archive', 'event_list');
     add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
 }
 /**
  * Gets all the payment methods which can be used for transaction
  * (according to the relations between payment methods and events, and
  * the currencies used for the transaction and their relation to payment methods)
  * @param EE_Transaction $transaction
  * @param string 	$scope @see EEM_Payment_Method::get_all_for_events
  * @return EE_Payment_Method[]
  */
 public function get_all_for_transaction($transaction, $scope)
 {
     //@todo take relations between events and payment methods into account, once that relation exists
     if ($transaction instanceof EE_Transaction) {
         //@todo take the relation between transaction and currencies into account
     }
     $currencies_for_events = array(EE_Config::instance()->currency->code);
     //give addons a chance to override what payment methods are chosen based on the transaction
     return apply_filters('FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', $this->get_all_active($scope, array(array('Currency.CUR_code' => array('IN', $currencies_for_events)))), $transaction, $scope);
 }
 /**
  * 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 $url
  * @param $ID
  * @return string
  */
 function get_edit_post_link($url, $ID)
 {
     //need to make sure we only edit links if our cpt
     global $post;
     if (!isset($this->_CPTs[$post->post_type])) {
         return $url;
     }
     //k made it here so all is good.
     $scheme = is_ssl() ? 'https' : 'http';
     $url = get_admin_url(EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme);
     // http://example.com/wp-admin/admin.php?page=espresso_events&action=edit&post=205&edit_nonce=0d403530d6
     return wp_nonce_url(add_query_arg(array('page' => $post->post_type, 'post' => $ID, 'action' => 'edit'), $url), 'edit', 'edit_nonce');
 }
 /**
  * plugin_uninstall
  *
  * @access public
  * @static
  * @param bool $remove_all
  * @return void
  */
 public static function delete_all_espresso_tables_and_data($remove_all = true)
 {
     global $wpdb;
     $undeleted_tables = array();
     // load registry
     foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
         if (method_exists($model_name, 'instance')) {
             $model_obj = call_user_func(array($model_name, 'instance'));
             if ($model_obj instanceof EEM_Base) {
                 foreach ($model_obj->get_tables() as $table) {
                     if (strpos($table->get_table_name(), 'esp_')) {
                         switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
                             case false:
                                 $undeleted_tables[] = $table->get_table_name();
                                 break;
                             case 0:
                                 // echo '<h4 style="color:red;">the table : ' . $table->get_table_name() . ' was not deleted  <br /></h4>';
                                 break;
                             default:
                                 // echo '<h4>the table : ' . $table->get_table_name() . ' was deleted successfully <br /></h4>';
                         }
                     }
                 }
             }
         }
     }
     //there are some tables whose models were removed.
     //they should be removed when removing all EE core's data
     $tables_without_models = array('esp_promotion', 'esp_promotion_applied', 'esp_promotion_object', 'esp_promotion_rule', 'esp_rule');
     foreach ($tables_without_models as $table) {
         EEH_Activation::delete_db_table_if_empty($table);
     }
     $wp_options_to_delete = array('ee_no_ticket_prices' => true, 'ee_active_messengers' => true, 'ee_has_activated_messenger' => true, 'ee_flush_rewrite_rules' => true, 'ee_config' => false, 'ee_data_migration_current_db_state' => true, 'ee_data_migration_mapping_' => false, 'ee_data_migration_script_' => false, 'ee_data_migrations' => true, 'ee_dms_map' => false, 'ee_notices' => true, 'lang_file_check_' => false, 'ee_maintenance_mode' => true, 'ee_ueip_optin' => true, 'ee_ueip_has_notified' => true, 'ee_plugin_activation_errors' => true, 'ee_id_mapping_from' => false, 'espresso_persistent_admin_notices' => true, 'ee_encryption_key' => true, 'pue_force_upgrade_' => false, 'pue_json_error_' => false, 'pue_install_key_' => false, 'pue_verification_error_' => false, 'pu_dismissed_upgrade_' => false, 'external_updates-' => false, 'ee_extra_data' => true, 'ee_ssn_' => false, 'ee_rss_' => false, 'ee_rte_n_tx_' => false, 'ee_pers_admin_notices' => true, 'ee_job_parameters_' => false, 'ee_upload_directories_incomplete' => true);
     if (is_main_site()) {
         $wp_options_to_delete['ee_network_config'] = true;
     }
     $undeleted_options = array();
     foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
         if ($no_wildcard) {
             if (!delete_option($option_name)) {
                 $undeleted_options[] = $option_name;
             }
         } else {
             $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%{$option_name}%'");
             foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
                 if (!delete_option($option_name_from_wildcard)) {
                     $undeleted_options[] = $option_name_from_wildcard;
                 }
             }
         }
     }
     //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
     remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
     if ($remove_all && ($espresso_db_update = get_option('espresso_db_update'))) {
         $db_update_sans_ee4 = array();
         foreach ($espresso_db_update as $version => $times_activated) {
             if ($version[0] == '3') {
                 //if its NON EE4
                 $db_update_sans_ee4[$version] = $times_activated;
             }
         }
         update_option('espresso_db_update', $db_update_sans_ee4);
     }
     $errors = '';
     if (!empty($undeleted_tables)) {
         $errors .= sprintf(__('The following tables could not be deleted: %s%s', 'event_espresso'), '<br/>', implode(',<br/>', $undeleted_tables));
     }
     if (!empty($undeleted_options)) {
         $errors .= !empty($undeleted_tables) ? '<br/>' : '';
         $errors .= sprintf(__('The following wp-options could not be deleted: %s%s', 'event_espresso'), '<br/>', implode(',<br/>', $undeleted_options));
     }
     if ($errors != '') {
         EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
     }
 }
 /**
  * _currency_support
  *
  * @access protected
  * @param \EE_Payment_Method $payment_method
  * @return \EE_Form_Section_Proper
  */
 protected function _currency_support(EE_Payment_Method $payment_method)
 {
     if (!$payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
         return new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice'))) . EEH_HTML::td(EEH_HTML::strong(sprintf(__('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), EE_Config::instance()->currency->code)))));
     } else {
         return new EE_Form_Section_HTML('');
     }
 }
 /**
  *
  * @param EE_Transaction       $transaction
  * @param float                $amount
  * @param EE_Billing_Info_Form $billing_info
  * @param string               $return_url
  * @param string                 $fail_url
  * @param string               $method
  * @param bool           $by_admin
  * @return EE_Payment
  * @throws EE_Error
  */
 function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false)
 {
     // @todo: add surcharge for the payment method, if any
     if ($this->_gateway) {
         //there is a gateway, so we're going to make a payment object
         //but wait! do they already have a payment in progress that we thought was failed?
         $duplicate_properties = array('STS_ID' => EEM_Payment::status_id_failed, 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $this->_pm_instance->ID(), 'PAY_source' => $method, 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), 'PAY_gateway_response' => null);
         $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
         //if we didn't already have a payment in progress for the same thing,
         //then we actually want to make a new payment
         if (!$payment instanceof EE_Payment) {
             $payment = EE_Payment::new_instance(array_merge($duplicate_properties, array('PAY_timestamp' => time(), 'PAY_txn_id_chq_nmbr' => null, 'PAY_po_number' => null, 'PAY_extra_accntng' => null, 'PAY_details' => null)));
         }
         //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
         $payment->save();
         $billing_values = $this->_get_billing_values_from_form($billing_info);
         //  Offsite Gateway
         if ($this->_gateway instanceof EE_Offsite_Gateway) {
             $payment = $this->_gateway->set_redirection_info($payment, $billing_values, $return_url, EE_Config::instance()->core->txn_page_url(array('e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), 'ee_payment_method' => $this->_pm_instance->slug())), $fail_url);
             $payment->save();
             //  Onsite Gateway
         } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
             $payment = $this->_gateway->do_direct_payment($payment, $billing_values);
             $payment->save();
         } else {
             throw new EE_Error(sprintf(__('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), get_class($this), gettype($this->_gateway)));
         }
     } else {
         // no gateway provided
         // there is no payment. Must be an offline gateway
         // create a payment object anyways, but dont save it
         $payment = EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $transaction->payment_method_ID(), 'PAY_amount' => 0.0, 'PAY_timestamp' => time()));
     }
     // if there is billing info, clean it and save it now
     if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
         $this->_save_billing_info_to_attendee($billing_info, $transaction);
     }
     return $payment;
 }
示例#27
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->config_path = EE_APPPATH . 'config/config.php';
     ee()->load->helper('language_helper');
 }
    /**
     * @return bool
     */
    public function schema_changes_before_migration()
    {
        //relies on 4.1's EEH_Activation::create_table
        require_once EE_HELPERS . 'EEH_Activation.helper.php';
        $table_name = 'esp_answer';
        $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tREG_ID INT UNSIGNED NOT NULL,\n\t\t\t\t\tQST_ID INT UNSIGNED NOT NULL,\n\t\t\t\t\tANS_value TEXT NOT NULL,\n\t\t\t\t\tPRIMARY KEY  (ANS_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_attendee_meta';
        $sql = "ATTM_ID INT(10) UNSIGNED NOT\tNULL AUTO_INCREMENT,\n\t\t\t\t\t\tATT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t\t\tATT_fname VARCHAR(45) NOT NULL,\n\t\t\t\t\t\tATT_lname VARCHAR(45) NOT\tNULL,\n\t\t\t\t\t\tATT_address VARCHAR(255) DEFAULT\tNULL,\n\t\t\t\t\t\tATT_address2 VARCHAR(255) DEFAULT\tNULL,\n\t\t\t\t\t\tATT_city VARCHAR(45) DEFAULT\tNULL,\n\t\t\t\t\t\tSTA_ID INT(10) DEFAULT\tNULL,\n\t\t\t\t\t\tCNT_ISO VARCHAR(45) DEFAULT\tNULL,\n\t\t\t\t\t\tATT_zip VARCHAR(12) DEFAULT\tNULL,\n\t\t\t\t\t\tATT_email VARCHAR(255) NOT NULL,\n\t\t\t\t\t\tATT_phone VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t\t\tPRIMARY KEY  (ATTM_ID),\n\t\t\t\t\t\t\t\tKEY ATT_fname (ATT_fname),\n\t\t\t\t\t\t\t\tKEY ATT_lname (ATT_lname),\n\t\t\t\t\t\t\t\tKEY ATT_email (ATT_email)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
        $table_name = 'esp_country';
        $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL,\n\t\t\t\t\t  CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  CNT_cur_code VARCHAR(6) COLLATE utf8_bin DEFAULT 'USD',\n\t\t\t\t\t  CNT_cur_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar',\n\t\t\t\t\t  CNT_cur_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars',\n\t\t\t\t\t  CNT_cur_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '\$',\n\t\t\t\t\t  CNT_cur_sign_b4 TINYINT(1) DEFAULT '1',\n\t\t\t\t\t  CNT_cur_dec_plc TINYINT(3) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\t\t  CNT_cur_dec_mrk VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '.',\n\t\t\t\t\t  CNT_cur_thsnds VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT ',',\n\t\t\t\t\t  CNT_tel_code VARCHAR(12) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\t  CNT_is_EU TINYINT(1) DEFAULT '0',\n\t\t\t\t\t  CNT_active TINYINT(1) DEFAULT '0',\n\t\t\t\t\t  PRIMARY KEY  (CNT_ISO)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_currency';
        $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,\n\t\t\t\tCUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar',\n\t\t\t\tCUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars',\n\t\t\t\tCUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '\$',\n\t\t\t\tCUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',\n\t\t\t\tCUR_active TINYINT(1) DEFAULT '0',\n\t\t\t\tPRIMARY KEY  (CUR_code)";
        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_currency_payment_method';
        $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tCUR_code  VARCHAR(6) COLLATE utf8_bin NOT NULL,\n\t\t\t\tPMD_ID INT(11) NOT NULL,\n\t\t\t\tPRIMARY KEY  (CPM_ID)";
        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
        $table_name = 'esp_datetime';
        $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t  EVT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t  DTT_name VARCHAR(255) NOT NULL DEFAULT '',\n\t\t\t\t  DTT_description TEXT NOT NULL,\n\t\t\t\t  DTT_EVT_start DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t  DTT_EVT_end DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t  DTT_reg_limit MEDIUMINT(8) DEFAULT -1,\n\t\t\t\t  DTT_sold MEDIUMINT(8) UNSIGNED DEFAULT 0,\n\t\t\t\t  DTT_is_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t  DTT_order MEDIUMINT(3) UNSIGNED DEFAULT 0,\n\t\t\t\t  DTT_parent INT(10) UNSIGNED DEFAULT 0,\n\t\t\t\t  DTT_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\t\tPRIMARY KEY  (DTT_ID),\n\t\t\t\t\t\tKEY EVT_ID (EVT_ID),\n\t\t\t\t\t\tKEY DTT_is_primary (DTT_is_primary)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_event_meta';
        $sql = "\n\t\t\tEVTM_ID INT NOT NULL AUTO_INCREMENT,\n\t\t\tEVT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\tEVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,\n\t\t\tEVT_display_ticket_selector TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,\n\t\t\tEVT_visible_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\tEVT_default_registration_status VARCHAR(3),\n\t\t\tEVT_phone VARCHAR(45) DEFAULT NULL,\n\t\t\tEVT_additional_limit TINYINT UNSIGNED NULL,\n\t\t\tEVT_member_only TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\tEVT_allow_overflow TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\tEVT_timezone_string VARCHAR(45) NULL,\n\t\t\tEVT_external_URL VARCHAR(200) NULL,\n\t\t\tEVT_donations TINYINT(1) NULL,\n\t\t\tPRIMARY KEY  (EVTM_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_event_question_group';
        $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tEVT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t\tQSG_ID INT UNSIGNED NOT NULL,\n\t\t\t\t\tEQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY  (EQG_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_event_venue';
        $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tEVT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tVNU_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tEVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\tPRIMARY KEY  (EVV_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_extra_meta';
        $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tOBJ_ID INT(11) DEFAULT NULL,\n\t\t\t\tEXM_type VARCHAR(45) DEFAULT NULL,\n\t\t\t\tEXM_key VARCHAR(45) DEFAULT NULL,\n\t\t\t\tEXM_value TEXT,\n\t\t\t\tPRIMARY KEY  (EXM_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_line_item';
        $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tLIN_code VARCHAR(245) NOT NULL DEFAULT '',\n\t\t\t\tTXN_ID INT(11) DEFAULT NULL,\n\t\t\t\tLIN_name VARCHAR(245) NOT NULL DEFAULT '',\n\t\t\t\tLIN_desc TEXT DEFAULT NULL,\n\t\t\t\tLIN_unit_price DECIMAL(10,3) DEFAULT NULL,\n\t\t\t\tLIN_percent DECIMAL(10,3) DEFAULT NULL,\n\t\t\t\tLIN_is_taxable TINYINT(1) DEFAULT 0,\n\t\t\t\tLIN_order int DEFAULT 0,\n\t\t\t\tLIN_parent int DEFAULT 0,\n\t\t\t\tLIN_type VARCHAR(25) NOT NULL,\n\t\t\t\tLIN_total DECIMAL(10,3) DEFAULT NULL,\n\t\t\t\tLIN_quantity INT(10) DEFAULT NULL,\n\t\t\t\tOBJ_ID INT(11) DEFAULT NULL,\n\t\t\t\tOBJ_type VARCHAR(45)DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (LIN_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_log';
        $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tLOG_time DATETIME DEFAULT NULL,\n\t\t\t\tOBJ_ID VARCHAR(45) DEFAULT NULL,\n\t\t\t\tOBJ_type VARCHAR(45) DEFAULT NULL,\n\t\t\t\tLOG_type VARCHAR(45) DEFAULT NULL,\n\t\t\t\tLOG_message TEXT,\n\t\t\t\tLOG_wp_user INT(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (LOG_ID)";
        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_message_template';
        $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tGRP_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\tMTP_context VARCHAR(50) NOT NULL,\n\t\t\t\t\tMTP_template_field VARCHAR(30) NOT NULL,\n\t\t\t\t\tMTP_content TEXT NOT NULL,\n\t\t\t\t\tPRIMARY KEY  (MTP_ID),\n\t\t\t\t\tKEY GRP_ID (GRP_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        EEH_Activation::drop_index('esp_message_template_group', 'EVT_ID');
        $table_name = 'esp_message_template_group';
        $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tMTP_user_id INT(10) NOT NULL DEFAULT '1',\n\t\t\t\t\tMTP_name VARCHAR(245) NOT NULL DEFAULT '',\n\t\t\t\t\tMTP_description VARCHAR(245) NOT NULL DEFAULT '',\n\t\t\t\t\tMTP_messenger VARCHAR(30) NOT NULL,\n\t\t\t\t\tMTP_message_type VARCHAR(50) NOT NULL,\n\t\t\t\t\tMTP_is_global TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\t\tMTP_is_override TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\t\tMTP_deleted TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\t\tMTP_is_active TINYINT(1) NOT NULL DEFAULT '1',\n\t\t\t\t\tPRIMARY KEY  (GRP_ID),\n\t\t\t\t\tKEY MTP_user_id (MTP_user_id)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_event_message_template';
        $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tEVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\tGRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY  (EMT_ID),\n\t\t\t\t\tKEY EVT_ID (EVT_ID),\n\t\t\t\t\tKEY GRP_ID (GRP_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_payment';
        $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tTXN_ID INT(10) UNSIGNED DEFAULT NULL,\n\t\t\t\t\tSTS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\tPAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\tPAY_source VARCHAR(45) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\tPAY_amount DECIMAL(10,3) DEFAULT NULL,\n\t\t\t\t\tPMD_ID INT(11) DEFAULT NULL,\n\t\t\t\t\tPAY_gateway_response TEXT COLLATE utf8_bin,\n\t\t\t\t\tPAY_txn_id_chq_nmbr VARCHAR(32) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\tPAY_po_number VARCHAR(32) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\tPAY_extra_accntng VARCHAR(45) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\tPAY_details TEXT COLLATE utf8_bin,\n\t\t\t\t\tPAY_redirect_url VARCHAR(300),\n\t\t\t\t\tPAY_redirect_args TEXT,\n\t\t\t\t\tPRIMARY KEY  (PAY_ID),\n\t\t\t\t\tKEY TXN_ID (TXN_ID),\n\t\t\t\t\tKEY PAY_timestamp (PAY_timestamp)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
        $table_name = 'esp_payment_method';
        $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tPMD_type VARCHAR(124) DEFAULT NULL,\n\t\t\t\tPMD_name VARCHAR(255) DEFAULT NULL,\n\t\t\t\tPMD_desc TEXT,\n\t\t\t\tPMD_admin_name VARCHAR(255) DEFAULT NULL,\n\t\t\t\tPMD_admin_desc TEXT,\n\t\t\t\tPMD_slug VARCHAR(124) DEFAULT NULL,\n\t\t\t\tPMD_order INT(11) DEFAULT NULL,\n\t\t\t\tPMD_debug_mode TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\tPMD_wp_user INT(11) NOT NULL DEFAULT '0',\n\t\t\t\tPMD_open_by_default TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\tPMD_button_url VARCHAR(1012) DEFAULT NULL,\n\t\t\t\tPMD_scope VARCHAR(255) NULL DEFAULT 'frontend',\n\t\t\t\tPRIMARY KEY  (PMD_ID),\n\t\t\t\tUNIQUE KEY PMD_slug_UNIQUE (PMD_slug)";
        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
        $table_name = "esp_ticket_price";
        $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  TKT_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  PRC_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  PRIMARY KEY  (TKP_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = "esp_datetime_ticket";
        $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  DTT_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  TKT_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  PRIMARY KEY  (DTK_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = "esp_ticket_template";
        $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  TTM_name VARCHAR(45) NOT NULL,\n\t\t\t\t\t  TTM_description TEXT,\n\t\t\t\t\t  TTM_file VARCHAR(45),\n\t\t\t\t\t  PRIMARY KEY  (TTM_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_question';
        $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
					QST_display_text TEXT NOT NULL,
					QST_admin_label VARCHAR(255) NOT NULL,
					QST_system VARCHAR(25) DEFAULT NULL,
					QST_type VARCHAR(25) NOT NULL DEFAULT "TEXT",
					QST_required TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
					QST_required_text VARCHAR(100) NULL,
					QST_order TINYINT UNSIGNED NOT NULL DEFAULT 0,
					QST_admin_only TINYINT(1) NOT NULL DEFAULT 0,
					QST_wp_user BIGINT UNSIGNED NULL,
					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
					PRIMARY KEY  (QST_ID)';
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_question_group_question';
        $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tQSG_ID INT UNSIGNED NOT NULL,\n\t\t\t\t\tQST_ID INT UNSIGNED NOT NULL,\n\t\t\t\t\tQGQ_order INT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY  (QGQ_ID) ";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_question_option';
        $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tQSO_value VARCHAR(255) NOT NULL,\n\t\t\t\t\tQSO_desc TEXT NOT NULL,\n\t\t\t\t\tQST_ID INT UNSIGNED NOT NULL,\n\t\t\t\t\tQSO_order INT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\tQSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY  (QSO_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_registration';
        $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  EVT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t\t  ATT_ID BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t\t  TXN_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  TKT_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL DEFAULT 'RPP',\n\t\t\t\t\t  REG_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t  REG_final_price DECIMAL(10,3) NOT NULL DEFAULT '0.00',\n\t\t\t\t\t  REG_session VARCHAR(45) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  REG_code VARCHAR(45) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\t  REG_url_link VARCHAR(64) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\t  REG_count TINYINT UNSIGNED DEFAULT '1',\n\t\t\t\t\t  REG_group_size TINYINT UNSIGNED DEFAULT '1',\n\t\t\t\t\t  REG_att_is_going TINYINT(1) DEFAULT '0',\n\t\t\t\t\t  REG_deleted TINYINT(1) DEFAULT '0',\n\t\t\t\t\t  PRIMARY KEY  (REG_ID),\n\t\t\t\t\t  KEY EVT_ID (EVT_ID),\n\t\t\t\t\t  KEY ATT_ID (ATT_ID),\n\t\t\t\t\t  KEY TXN_ID (TXN_ID),\n\t\t\t\t\t  KEY TKT_ID (TKT_ID),\n\t\t\t\t\t  KEY STS_ID (STS_ID),\n\t\t\t\t\t  KEY REG_url_link (REG_url_link),\n\t\t\t\t\t  KEY REG_code (REG_code)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
        $table_name = 'esp_checkin';
        $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tREG_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\tDTT_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\tCHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,\n\t\t\t\t\tCHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\tPRIMARY KEY  (CHK_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_state';
        $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  STA_active TINYINT(1) DEFAULT '1',\n\t\t\t\t\t  PRIMARY KEY  (STA_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_status';
        $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,\n\t\t\t\t\t  STS_can_edit TINYINT(1) NOT NULL DEFAULT 0,\n\t\t\t\t\t  STS_desc TINYTEXT COLLATE utf8_bin,\n\t\t\t\t\t  STS_open TINYINT(1) NOT NULL DEFAULT 1,\n\t\t\t\t\t  UNIQUE KEY STS_ID_UNIQUE (STS_ID),\n\t\t\t\t\t  KEY STS_type (STS_type)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_transaction';
        $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t  TXN_total DECIMAL(10,3) DEFAULT '0.00',\n\t\t\t\t\t  TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00',\n\t\t\t\t\t  STS_ID VARCHAR(3) NOT NULL DEFAULT 'TOP',\n\t\t\t\t\t  TXN_session_data TEXT COLLATE utf8_bin,\n\t\t\t\t\t  TXN_hash_salt VARCHAR(250) COLLATE utf8_bin DEFAULT NULL,\n\t\t\t\t\t  PMD_ID INT(11) DEFAULT NULL,\n\t\t\t\t\t  TXN_reg_steps TEXT,\n\t\t\t\t\t  PRIMARY KEY  (TXN_ID),\n\t\t\t\t\t  KEY TXN_timestamp (TXN_timestamp),\n\t\t\t\t\t  KEY STS_ID (STS_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = 'esp_venue_meta';
        $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\tVNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,\n\t\t\tVNU_address VARCHAR(255) DEFAULT NULL,\n\t\t\tVNU_address2 VARCHAR(255) DEFAULT NULL,\n\t\t\tVNU_city VARCHAR(100) DEFAULT NULL,\n\t\t\tSTA_ID INT(11) DEFAULT NULL,\n\t\t\tCNT_ISO VARCHAR(2) DEFAULT NULL,\n\t\t\tVNU_zip VARCHAR(45) DEFAULT NULL,\n\t\t\tVNU_phone VARCHAR(45) DEFAULT NULL,\n\t\t\tVNU_capacity INT(11) DEFAULT NULL,\n\t\t\tVNU_url VARCHAR(255) DEFAULT NULL,\n\t\t\tVNU_virtual_phone VARCHAR(45) DEFAULT NULL,\n\t\t\tVNU_virtual_url VARCHAR(255) DEFAULT NULL,\n\t\t\tVNU_enable_for_gmap TINYINT(1) DEFAULT '0',\n\t\t\tVNU_google_map_link VARCHAR(255) DEFAULT NULL,\n\t\t\tPRIMARY KEY  (VNUM_ID),\n\t\t\tKEY STA_ID (STA_ID),\n\t\t\tKEY CNT_ISO (CNT_ISO)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        //modified tables
        $table_name = "esp_price";
        $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  PRT_ID TINYINT(3) UNSIGNED NOT NULL,\n\t\t\t\t\t  PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00',\n\t\t\t\t\t  PRC_name VARCHAR(245) NOT NULL,\n\t\t\t\t\t  PRC_desc TEXT,\n\t\t\t\t\t  PRC_is_default TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',\n\t\t\t\t\t  PRC_overrides INT(10) UNSIGNED DEFAULT NULL,\n\t\t\t\t\t  PRC_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  PRC_order TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  PRC_wp_user BIGINT UNSIGNED NULL,\n\t\t\t\t\t  PRC_parent INT(10) UNSIGNED DEFAULT 0,\n\t\t\t\t\t  PRIMARY KEY  (PRC_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        $table_name = "esp_price_type";
        $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t  PRT_name VARCHAR(45) NOT NULL,\n\t\t\t\t  PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',\n\t\t\t\t  PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\t  PRT_order TINYINT UNSIGNED NULL,\n\t\t\t\t  PRT_wp_user BIGINT UNSIGNED NULL,\n\t\t\t\t  PRT_deleted TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\t  UNIQUE KEY PRT_name_UNIQUE (PRT_name),\n\t\t\t\t  PRIMARY KEY  (PRT_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
        $table_name = "esp_ticket";
        $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  TTM_ID INT(10) UNSIGNED NOT NULL,\n\t\t\t\t\t  TKT_name VARCHAR(245) NOT NULL DEFAULT '',\n\t\t\t\t\t  TKT_description TEXT NOT NULL,\n\t\t\t\t\t  TKT_qty MEDIUMINT(8) DEFAULT NULL,\n\t\t\t\t\t  TKT_sold MEDIUMINT(8) NOT NULL DEFAULT 0,\n\t\t\t\t\t  TKT_uses TINYINT NOT NULL DEFAULT '-1',\n\t\t\t\t\t  TKT_required TINYINT UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  TKT_min TINYINT UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  TKT_max TINYINT NOT NULL DEFAULT '-1',\n\t\t\t\t\t  TKT_price DECIMAL(10,3) NOT NULL DEFAULT '0.00',\n\t\t\t\t\t  TKT_start_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t  TKT_end_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t  TKT_taxable TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  TKT_order TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  TKT_row TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  TKT_is_default TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\t\t  TKT_wp_user BIGINT UNSIGNED NULL,\n\t\t\t\t\t  TKT_parent INT(10) UNSIGNED DEFAULT '0',\n\t\t\t\t\t  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',\n\t\t\t\t\t  PRIMARY KEY  (TKT_ID)";
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        EEH_Activation::drop_index('esp_question_group', 'QSG_identifier_UNIQUE');
        $table_name = 'esp_question_group';
        $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
					QSG_name VARCHAR(255) NOT NULL,
					QSG_identifier VARCHAR(100) NOT NULL,
					QSG_desc TEXT NULL,
					QSG_order TINYINT UNSIGNED NOT NULL DEFAULT 0,
					QSG_show_group_name TINYINT(1) NOT NULL,
					QSG_show_group_desc TINYINT(1) NOT NULL,
					QSG_system TINYINT NULL,
					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
					QSG_wp_user BIGINT UNSIGNED NULL,
					PRIMARY KEY  (QSG_ID),
					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
        //(because many need to convert old string states to foreign keys into the states table)
        $script_4_1_defaults->insert_default_states();
        $script_4_1_defaults->insert_default_countries();
        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
        $script_4_5_defaults->insert_default_price_types();
        $script_4_5_defaults->insert_default_prices();
        $script_4_5_defaults->insert_default_tickets();
        //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
        EE_Config::instance()->update_espresso_config(false, true);
        $this->add_default_admin_only_payments();
        $this->insert_default_currencies();
        return true;
    }
 /**
  * gets the class's config object
  *
  * @return EE_Config_Base
  */
 public function config()
 {
     if (empty($this->_config)) {
         $this->_config = EE_Config::instance()->get_config($this->config_section(), $this->config_name(), $this->config_class());
     }
     return $this->_config;
 }
 /**
  * All the message triggers done by route go in here.
  *
  * @since 4.5.0
  *
  * @return void
  */
 protected static function _register_routes()
 {
     EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
     do_action('AHEE__EED_Messages___register_routes');
 }