/**
  * assuming we have an up-to-date database schema, this will populate it
  * with default and initial data. This should be called
  * upon activation of a new plugin, reactivation, and at the end
  * of running migration scripts
  */
 public static function initialize_db_content()
 {
     //let's avoid doing all this logic repeatedly, especially when addons are requesting it
     if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
         return;
     }
     EEH_Activation::$_initialized_db_content_already_in_this_request = true;
     EEH_Activation::initialize_system_questions();
     EEH_Activation::insert_default_status_codes();
     EEH_Activation::generate_default_message_templates();
     EEH_Activation::create_no_ticket_prices_array();
     EE_Registry::instance()->CAP->init_caps();
     EEH_Activation::validate_messages_system();
     EEH_Activation::insert_default_payment_methods();
     //in case we've
     EEH_Activation::remove_cron_tasks();
     EEH_Activation::create_cron_tasks();
     //also, check for CAF default db content
     do_action('AHEE__EEH_Activation__initialize_db_content');
     //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
     //which users really won't care about on initial activation
     EE_Error::overwrite_success();
 }
 /**
  * assuming we have an up-to-date database schema, this will populate it
  * with default and initial data. This should be called
  * upon activation of a new plugin, reactivation, and at the end
  * of running migration scripts
  */
 public static function initialize_db_content()
 {
     //		echo"init reg content";
     EEH_Activation::initialize_system_questions();
     //		EEH_Activation::insert_default_prices();
     //		EEH_Activation::insert_defaulinsert_default_pricest_price_types();
     //		EEH_Activation::insert_default_tickets();
     EEH_Activation::insert_default_status_codes();
     //		default countries and states actually takes place during data migration scripts
     //		because converting state and coutnry names to foreign keys must occur for venues, attendees, etc
     //		EEH_Activation::insert_default_countries();
     //		EEH_Activation::insert_default_states();
     EEH_Activation::generate_default_message_templates();
     EEH_Activation::create_no_ticket_prices_array();
     //also initialize payment settings, which is a side-effect of calling
     //EEM_Gateway::load_all_gateways()
     EEM_Gateways::instance(true)->load_all_gateways();
     //also, check for CAF default db content
     do_action('AHEE__EEH_Activation__initialize_db_content');
     //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
     //which users really won't care about on initial activation
     EE_Error::overwrite_success();
 }
 /**
  * This tests the generate_default_message_templates method with using the
  * FHEE__EE_messenger__get_default_message_types__default_types filter to add a
  * bogus message_type string.  No errors should be triggered, and the invalid default mt
  * should NOT be added to the active array for the messenger.
  *
  * @since 4.6
  * @group 7595
  */
 public function test_filtered_default_message_types_on_activation()
 {
     EE_Registry::instance()->load_helper('MSG_Template');
     EE_Registry::instance()->load_helper('Activation');
     //let's clear out all active messengers to get an accurate test of initial generation of message templates.
     global $wpdb;
     $mtpg_table = $wpdb->prefix . 'esp_message_template_group';
     $mtp_table = $wpdb->prefix . 'esp_message_template';
     $evt_mtp_table = $wpdb->prefix . 'esp_event_message_template';
     $query = "DELETE FROM  {$mtpg_table} WHERE 'GRP_ID' > 0";
     $wpdb->query($query);
     $query = "DELETE FROM {$mtp_table} WHERE 'MTP_ID' > 0";
     $wpdb->query($query);
     $query = "DELETE FROM {$evt_mtp_table} WHERE 'EMT_ID' > 0";
     $wpdb->query($query);
     EEH_MSG_Template::update_active_messengers_in_db(array());
     //set a filter for the invalid message type
     add_filter('FHEE__EE_messenger__get_default_message_types__default_types', function ($default_types, $messenger) {
         $default_types[] = 'bogus_message_type';
         return $default_types;
     }, 10, 2);
     //activate messages... if there's any problems then errors will trigger a fail.
     EEH_Activation::generate_default_message_templates();
     //all went well so let's make sure the activated system does NOT have our invalid message type string.
     $active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
     foreach ($active_messengers as $messenger => $settings) {
         $this->assertFalse(isset($settings['settings'][$messenger . '-message_types']['bogus_message_type']), sprintf('The %s messenger should not have "bogus_message_type" active on it but it does.', $messenger));
     }
 }
 /**
  * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of.
  */
 public static function set_defaults()
 {
     //only set defaults if we're not in EE_Maintenance mode
     EE_Registry::instance()->load_helper('Activation');
     EEH_Activation::generate_default_message_templates();
     //for any message types with force activation, let's ensure they are activated
     foreach (self::$_ee_message_type_registry as $mtname => $settings) {
         if ($settings['force_activation']) {
             $MSG = new EE_Messages();
             foreach ($settings['messengers_to_activate_with'] as $messenger) {
                 $MSG->ensure_message_type_is_active($mtname, $messenger);
             }
         }
     }
 }