/**
  * _request_filesystem_credentials
  * if attempting to enable full logging, WordPress may require filesystem credentials for FTP or SSH depending on the server
  *
  * @access   protected
  * @param bool $show_errors
  * @return bool
  */
 protected function _request_filesystem_credentials($show_errors = TRUE)
 {
     require_once ABSPATH . 'wp-admin/includes/file.php';
     $url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'request_filesystem_credentials'), $this->_admin_base_url);
     $credentials = request_filesystem_credentials($url);
     if ($credentials == FALSE) {
         if ($show_errors) {
             EE_Error::get_notices(FALSE);
             EE_Error::reset_notices();
             EE_Error::add_error(__('Connection settings are missing or incorrect. Please verify that the connection settings below are correct.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', '__return_false');
         }
         return FALSE;
     }
     // now we have some credentials, try to get the wp_filesystem running
     $WP_Filesystem = WP_Filesystem($credentials);
     if (!$WP_Filesystem) {
         if ($show_errors) {
             EE_Error::get_notices(FALSE);
             EE_Error::reset_notices();
             EE_Error::add_error(__('There was an error connecting to the server. Please verify that the connection settings below are correct.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', '__return_false');
         }
         // our credentials were no good, ask the user for them again
         request_filesystem_credentials($url);
         return FALSE;
     }
     EE_Registry::instance()->CFG->admin->use_full_logging = TRUE;
     return TRUE;
 }
 /**
  *	_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()->core instanceof EE_Core_Config) {
         throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
     }
     // name of the WP Posts Page
     $posts_page = $this->_get_page_for_posts();
     // make sure critical pages get removed
     $this->_update_post_shortcodes($posts_page);
     // save updated config, but don't add errors
     if (!EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
         EE_Error::add_error(__('The Event Espresso Configuration Settings were not updated when attempting to save the "critical page post shortcodes".', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
     // check for errors
     $notices = EE_Error::get_notices(FALSE);
     // any errors to report?
     if (isset($notices['errors'])) {
         foreach ($notices as $value) {
             $this->add_error($value);
         }
     }
     //regardless of whether it worked or not, we ought to continue the migration
     $this->set_completed();
     return 1;
 }
 /**
  * Removes the relation to the specified term taxonomy, and maintains the
  * data integrity of the term taxonomy provided
  * @param EE_Term_Taxonomy $term_taxonomy
  * @return EE_Base_Class the relation was removed from
  */
 function remove_relation_to_term_taxonomy($term_taxonomy)
 {
     if (!$term_taxonomy) {
         EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__);
         return NULL;
     }
     $term_taxonomy->set_count($term_taxonomy->count() - 1);
     $term_taxonomy->save();
     return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy');
 }
 /**
  * constructor for questions
  * @param \EE_Question $QST EE_Question object
  * @param \EE_Answer   $ANS EE_Answer object
  * @param array               $q_meta
  * @access public
  * @return \EE_Question_Form_Input
  */
 public function __construct(EE_Question $QST = NULL, EE_Answer $ANS = NULL, $q_meta = array())
 {
     if (empty($QST) || empty($ANS)) {
         EE_Error::add_error(__('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return NULL;
     }
     $this->_QST = $QST;
     $this->_ANS = $ANS;
     $this->set_question_form_input_meta($q_meta);
     $this->set_question_form_input_init();
 }
Ejemplo n.º 5
0
 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__);
     }
 }
 /**
  * When setting, just verify that the value being used matches what we've defined as allowable enum values.
  * If not, throw an error (but if WP_DEBUG is false, just set the value to default)
  * @param string $value_inputted_for_field_on_model_object
  * @return string
  * @throws EE_Error
  */
 function prepare_for_set($value_inputted_for_field_on_model_object)
 {
     if ($value_inputted_for_field_on_model_object !== null && !array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)) {
         if (defined('WP_DEBUG') && WP_DEBUG) {
             $msg = sprintf(__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'), $value_inputted_for_field_on_model_object, $this->_name);
             $msg2 = sprintf(__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'), $this->_name, implode(", ", array_keys($this->_allowed_enum_values)), $value_inputted_for_field_on_model_object);
             EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
         }
         return $this->get_default_value();
     }
     return $value_inputted_for_field_on_model_object;
 }
 /**
  * 	run - initial module setup
  *
  *  @access 	public
  *  @return 	void
  */
 public function run($WP)
 {
     if (is_readable(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php')) {
         require_once EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php';
     } else {
         $msg = __('The Invoice.class.php file could not be loaded.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
     }
     //		add_filter( 'FHEE_load_ee_config', '__return_true' );
     //		add_filter( 'FHEE_run_EE_wp', '__return_true' );
     //		add_filter( 'FHEE_load_EE_Session', '__return_true' );
     //		add_action( 'wp_loaded', array( $this, 'wp_loaded' ));
     //		add_action( 'wp', array( $this, 'wp' ));
     //		add_filter( 'the_content', array( $this, 'the_content' ));
 }
function load_espresso_calendar_class()
{
    // check for duplicate copy of Calendar addon
    if (class_exists('EE_Calendar')) {
        EE_Error::add_error(sprintf(__('It appears there are multiple copies of the Event Espresso Calendar installed on your server.%sPlease remove (delete) all copies except for this version: "%s"', 'event_espresso'), '<br />', EE_CALENDAR_VERSION), __FILE__, __FUNCTION__, __LINE__);
        add_action('admin_notices', 'espresso_calendar_activation_error');
        return;
    }
    // todo: remove version check since this has been added to later versions of register_addon in EE core
    if (class_exists('EE_Addon') && version_compare(EVENT_ESPRESSO_VERSION, EE_CORE_VERSION_REQUIRED, '>=')) {
        // calendar_version
        require_once plugin_dir_path(__FILE__) . 'EE_Calendar.class.php';
        EE_Calendar::register_addon();
    } else {
        add_action('admin_notices', 'espresso_calendar_activation_error');
    }
}
 /**
  * _add_query_arg
  * adds nonce to array of arguments then calls WP add_query_arg function
  *
  * @access public
  * @param array       $args
  * @param string $url
  * @return string
  */
 public static function add_query_args_and_nonce($args = array(), $url = '')
 {
     if (empty($url)) {
         $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso');
         $dev_msg = $user_msg . "\n" . sprintf(__('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'), __CLASS__);
         EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
     }
     // check that an action exists
     if (isset($args['action']) && !empty($args['action'])) {
         $args = array_merge($args, array($args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce')));
     } else {
         $args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')));
     }
     //finally, let's always add a return address (if present) :)
     $args = !empty($_REQUEST['action']) ? array_merge($args, array('return' => $_REQUEST['action'])) : $args;
     return add_query_arg($args, $url);
 }
 /**
  *    format - output formatted EE object address information
  *
  * @access public
  * @param         object      EEI_Address $obj_with_address
  * @param string  $type       how the address is formatted. for example: 'multiline' or 'inline'
  * @param boolean $use_schema whether to apply schema.org formatting to the address
  * @param bool    $add_wrapper
  * @return string
  */
 public static function format($obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true)
 {
     // check that incoming object implements the EEI_Address interface
     if (!$obj_with_address instanceof EEI_Address) {
         $msg = __('The address could not be formatted.', 'event_espresso');
         $dev_msg = __('The Address Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso');
         EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     // obtain an address formatter
     $formatter = EEH_Address::_get_formatter($type);
     // apply schema.org formatting ?
     $use_schema = !is_admin() ? $use_schema : false;
     $formatted_address = $use_schema ? EEH_Address::_schema_formatting($formatter, $obj_with_address) : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
     $formatted_address = $add_wrapper && !$use_schema ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' : $formatted_address;
     // return the formatted address
     return $formatted_address;
 }
Ejemplo n.º 11
0
 /**
  * Set redirection info
  *
  * @see https://github.com/eventespresso/event-espresso-core/blob/4.6.17.p/core/libraries/payment_methods/EE_Offsite_Gateway.lib.php#L51-L59
  *
  * @param EEI_Payment $payment
  * @param type $billing_info
  * @param type $return_url
  * @param type $cancel_url
  */
 public function set_redirection_info($ee_payment, $billing_info = array(), $return_url = null, $notify_url = null, $cancel_url = null)
 {
     $pronamic_gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->_config_id);
     if ($pronamic_gateway) {
         $transaction = $ee_payment->transaction();
         $total_line_item = $transaction->total_line_item();
         $data = new Pronamic_WP_Pay_Extensions_EventEspresso_PaymentData($this, $total_line_item, $transaction);
         $pronamic_payment = Pronamic_WP_Pay_Plugin::start($this->_config_id, $pronamic_gateway, $data);
         $error = $pronamic_gateway->get_error();
         if (is_wp_error($error)) {
             // @see https://github.com/eventespresso/event-espresso-core/blob/4.6.18.p/caffeinated/payment_methods/Mijireh/EEG_Mijireh.gateway.php#L147
             $error_message = sprintf(__('Errors communicating with gateway: %s', 'pronamic_ideal'), implode(',', $error->get_error_messages()));
             EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
             throw new EE_Error($error_message);
         } else {
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_return', $return_url);
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_success', $return_url);
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_cancel', $cancel_url);
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_error', $cancel_url);
             $redirect_url = $pronamic_payment->get_action_url();
             $redirect_args = $pronamic_gateway->get_output_fields();
             /*
              * Since Event Espresso uses an HTML form to redirect users to the payment gateway
              * we have to make sure an POST method is used when the redirect URL has query arguments.
              * Otheriwse the URL query arguments will be stripped by the users webbrowser.
              * Herefor we have to make sure the redirect arguments array is not empty.
              *
              * @see https://github.com/eventespresso/event-espresso-core/blob/4.6.18.p/core/db_classes/EE_Payment.class.php#L547
              * @see http://stackoverflow.com/q/1116019
              */
             if (false !== strpos($redirect_url, '?') && empty($redirect_args)) {
                 $redirect_args[] = '';
             }
             $ee_payment->set_redirect_url($redirect_url);
             $ee_payment->set_redirect_args($redirect_args);
         }
     } else {
         $error = Pronamic_WP_Pay_Plugin::get_default_error_message();
         // @see https://github.com/eventespresso/event-espresso-core/blob/4.6.18.p/caffeinated/payment_methods/Mijireh/EEG_Mijireh.gateway.php#L147
         throw new EE_Error($error);
     }
     return $ee_payment;
 }
/**
 * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165
 * it is preferred to instead use _update_attendee_registration_form_new() which
 * also better handles form validation. Exits
 * @param EE_Admin_Page $admin_page
 * @return void
 */
function ee_deprecated_update_attendee_registration_form_old($admin_page)
{
    //check if the old hooks are in use. If not, do the default
    if (!ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() || !$admin_page instanceof EE_Admin_Page) {
        return;
    }
    $req_data = $admin_page->get_request_data();
    $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE;
    $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE;
    $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
    if (!$REG_ID || !$qstns) {
        EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
    }
    $success = TRUE;
    // allow others to get in on this awesome fun   :D
    do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns);
    // loop thru questions... FINALLY!!!
    foreach ($qstns as $QST_ID => $qstn) {
        //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
        if (!is_array($qstn)) {
            $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
            continue;
        }
        foreach ($qstn as $ANS_ID => $ANS_value) {
            //get answer
            $query_params = array(0 => array('ANS_ID' => $ANS_ID, 'REG_ID' => $REG_ID, 'QST_ID' => $QST_ID));
            $answer = EEM_Answer::instance()->get_one($query_params);
            //this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
            if (!$answer instanceof EE_Answer) {
                $set_values = array('QST_ID' => $QST_ID, 'REG_ID' => $REG_ID, 'ANS_value' => $qstn);
                $success = EEM_Answer::instance()->insert($set_values);
                continue 2;
            }
            $answer->set('ANS_value', $ANS_value);
            $success = $answer->save();
        }
    }
    $what = __('Registration Form', 'event_espresso');
    $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
    $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
    exit;
}
 /**
  *  Gets the URL that the user should generally be sent back to after payment completion offiste
  *  Adds the reg_url_link in order to remember which session we were in the middle of processing
  * @param EE_Registration or int, current registration we want to link back to in the return url.
  * @param boolean $urlencode whether or not to url-encode the url (if true, you probably intend to pass
  * this string as a URL parameter itself, or maybe a post parameter)
  *  @return string URL on the current site of the thank_you page, with parameters added on to know which registration was just 
  * processed in order to correctly display the payment status. And it gets URL-encoded by default
  */
 protected function _get_notify_url($registration, $urlencode = false)
 {
     //if $registration is an ID instead of an EE_Registration, make it an EE_Registration
     if (!$registration instanceof EE_Registration) {
         $registration = $this->_REG->get_one_by_ID($registration);
     }
     if (empty($registration)) {
         $msg[0] = __("Cannot get Notify URL for gateway. Invalid registration", 'event_espresso');
         $msg[1] = sprinf(__("Registration being used is %s.", 'event_espresso'), print_r($registration, true));
         EE_Error::add_error(implode("||", $msg), __FILE__, __FUNCTION__, __LINE__);
         return '';
     }
     //get a registration that's currently getting processed
     /*@var $registration EE_Registration */
     $url = add_query_arg(array('e_reg_url_link' => $registration->reg_url_link(), 'ee_gateway' => $this->_gateway_name), get_permalink(EE_Registry::instance()->CFG->core->txn_page_id));
     if ($urlencode) {
         $url = urlencode($url);
     }
     return $url;
 }
 private function _insert_term($update = FALSE, $taxonomy = 'espresso_people_categories')
 {
     if ($taxonomy == 'espresso_people_categories') {
         $term_id = $update ? $this->_req_data['PER_CAT_ID'] : '';
     } else {
         $term_id = $update ? $this->_req_data['PER_TYPE_ID'] : '';
     }
     $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
     $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
     $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
     $term_args = array('name' => $category_name, 'description' => $category_desc, 'parent' => $category_parent);
     //was the category_identifier input disabled?
     if (isset($this->_req_data['category_identifier'])) {
         $term_args['slug'] = $this->_req_data['category_identifier'];
     }
     $insert_ids = $update ? wp_update_term($term_id, $taxonomy, $term_args) : wp_insert_term($category_name, $taxonomy, $term_args);
     if (!is_array($insert_ids)) {
         $msg = $taxonomy == 'espresso_people_categories' ? __('An error occurred and the category has not been saved to the database.', 'event_espresso') : __('An error occurred and the people type has not been saved to the database.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
     } else {
         $term_id = $insert_ids['term_id'];
         $msg = $taxonomy == 'espresso_people_categories' ? sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name) : sprintf(__('The people type %s was successfuly saved', 'event_espresso'), $category_name);
         EE_Error::add_success($msg);
     }
     return $term_id;
 }
 /**
  *		get_options_for_question
  *
  * 		@access		public
  * 		@param		string		$QST_IDs  csv list of $QST IDs
  *		@return 		array
  */
 public function get_options_for_question($QST_IDs)
 {
     if (empty($QST_IDs)) {
         EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return FALSE;
     }
     return EE_Registry::instance()->load_model('Question_Option')->get_all(array(array('Question.QST_ID' => array('IN', $QST_IDs), 'QSO_deleted' => FALSE), 'order_by' => 'QSO_ID'));
 }
Ejemplo n.º 16
0
 /**
  *			@process export name to create a suitable filename
  *		  @access private
  *		  @param string - export_name
  *			@return string on success, FALSE on fail
  */
 private function generate_filename($export_name = '')
 {
     if ($export_name != '') {
         $filename = get_bloginfo('name') . '-' . $export_name;
         $filename = sanitize_key($filename) . '-' . $this->today;
         return $filename;
     } else {
         EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
     }
     return false;
 }
 /**
  * create_upload_directories
  * Creates folders in the uploads directory to facilitate addons and templates
  *
  * 	@access public
  * 	@static
  * 	@return boolean success of verifying upload directories exist
  */
 public static function create_upload_directories()
 {
     EE_Registry::instance()->load_helper('File');
     // Create the required folders
     $folders = array(EVENT_ESPRESSO_TEMPLATE_DIR, EVENT_ESPRESSO_GATEWAY_DIR, EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', EVENT_ESPRESSO_UPLOAD_DIR . 'css/', EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/');
     foreach ($folders as $folder) {
         try {
             EEH_File::ensure_folder_exists_and_is_writable($folder);
             @chmod($folder, 0755);
         } catch (EE_Error $e) {
             EE_Error::add_error(sprintf(__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), $folder, '<br />' . $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
             //indicate we'll need to fix this later
             update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
             return FALSE;
         }
     }
     //just add the .htaccess file to the logs directory to begin with. Even if logging
     //is disabled, there might be activation errors recorded in there
     EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
     //remember EE's folders are all good
     delete_option(EEH_Activation::upload_directories_incomplete_option_name);
     return TRUE;
 }
 /**
  * Saves the billing info onto the attendee of the primary registrant on this transaction, and
  * cleans it first.
  * @param EE_Billing_Attendee_Info_Form $billing_form
  * @param EE_Transaction $transaction
  * @return boolean success
  */
 protected function _save_billing_info_to_attendee($billing_form, $transaction)
 {
     if (!$transaction || !$transaction instanceof EE_Transaction) {
         EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     $primary_reg = $transaction->primary_registration();
     if (!$primary_reg) {
         EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     $attendee = $primary_reg->attendee();
     if (!$attendee) {
         EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
 }
 /**
  *    adds a ticket to the cart
  * @access   private
  * @param EE_Ticket $ticket
  * @param int       $qty
  * @return TRUE on success, FALSE on fail
  */
 private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1)
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     // get the number of spaces left for this datetime ticket
     $available_spaces = self::_ticket_datetime_availability($ticket);
     // compare available spaces against the number of tickets being purchased
     if ($available_spaces >= $qty) {
         // allow addons to prevent a ticket from being added to cart
         if (!apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) {
             return false;
         }
         // add event to cart
         if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
             self::_recalculate_ticket_datetime_availability($ticket, $qty);
             return true;
         } else {
             return false;
         }
     } else {
         // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
         $available_spaces = self::_ticket_datetime_availability($ticket, true);
         // greedy greedy greedy eh?
         if ($available_spaces > 0) {
             // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces
             EE_Error::add_error(sprintf(_n('We\'re sorry, but there is only %s available space left for this event at this particular date and time.%sPlease select a different number (or different combination) of tickets.', 'We\'re sorry, but there are only %s available spaces left for this event at this particular date and time.%sPlease select a different number (or different combination) of tickets.', $available_spaces, 'event_espresso'), $available_spaces, '<br />'), __FILE__, __FUNCTION__, __LINE__);
         } else {
             EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
         return false;
     }
 }
 /**
  * callback for updating template settings
  *
  * @since 4.6.18.rc.006
  *
  * @param EE_Template_Config $CFG
  * @param array             $REQ incoming request
  *
  * @return void
  */
 public static function update_template_settings(EE_Template_Config $CFG, $REQ)
 {
     if (!isset($CFG->EED_Ticket_Selector)) {
         $CFG->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
     }
     try {
         $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
         //check for form submission
         if ($ticket_selector_form->was_submitted()) {
             //capture form data
             $ticket_selector_form->receive_form_submission();
             //validate form data
             if ($ticket_selector_form->is_valid()) {
                 //grab validated data from form
                 $valid_data = $ticket_selector_form->valid_data();
                 //set data on config
                 $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
                 $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
                 $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
             } else {
                 if ($ticket_selector_form->submission_error_message() != '') {
                     EE_Error::add_error($ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
                 }
             }
         }
     } catch (EE_Error $e) {
         $e->get_error();
     }
     return $CFG;
 }
Ejemplo n.º 21
0
 /**
  * garbage_collection
  * @since 4.3.0
  */
 public function garbage_collection()
 {
     // only perform during regular requests
     if (!defined('DOING_AJAX') || !DOING_AJAX) {
         /** @type WPDB $wpdb */
         global $wpdb;
         // since transient expiration timestamps are set in the future, we can compare against NOW
         $expiration = time();
         $too_far_in_the_the_future = $expiration + $this->_lifespan * 2;
         // filter the query limit. Set to 0 to turn off garbage collection
         $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50));
         // non-zero LIMIT means take out the trash
         if ($expired_session_transient_delete_query_limit) {
             $SQL = "\n\t\t\t\t\tSELECT option_name\n\t\t\t\t\tFROM {$wpdb->options}\n\t\t\t\t\tWHERE option_name\n\t\t\t\t\tLIKE '\\_transient\\_timeout\\_ee\\_ssn\\_%'\n\t\t\t\t\tAND ( option_value < {$expiration}\n\t\t\t\t\tOR option_value > {$too_far_in_the_the_future} )\n\t\t\t\t\tLIMIT {$expired_session_transient_delete_query_limit}\n\t\t\t\t";
             $expired_sessions = $wpdb->get_col($SQL);
             // valid results?
             if (!$expired_sessions instanceof WP_Error && !empty($expired_sessions)) {
                 // format array of results into something usable within the actual DELETE query's IN clause
                 $expired = array();
                 foreach ($expired_sessions as $expired_session) {
                     $expired[] = "'" . $expired_session . "'";
                     $expired[] = "'" . str_replace('timeout_', '', $expired_session) . "'";
                 }
                 $expired = implode(', ', $expired);
                 $SQL = "\n\t\t\t\t\t\tDELETE FROM {$wpdb->options}\n\t\t\t\t\t\tWHERE option_name\n\t\t\t\t\t\tIN ( {$expired} );\n\t\t\t\t\t ";
                 $results = $wpdb->query($SQL);
                 // if something went wrong, then notify the admin
                 if ($results instanceof WP_Error && is_admin()) {
                     EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
                 }
             }
             do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit);
         }
     }
 }
 /**
  * Gets an array of primary keys from the model objects. If you acquired the model objects
  * using EEM_Base::get_all() you don't need to call this (and probably shouldn't because
  * this is duplicated effort and reduces efficiency) you would be better to use
  * array_keys() on $model_objects.
  * @param /EE_Base_Class[] $model_objects
  * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array
  * @return array
  */
 public function get_IDs($model_objects, $filter_out_empty_ids = false)
 {
     if (!$this->has_primary_key_field()) {
         if (WP_DEBUG) {
             EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             return array();
         }
     }
     $IDs = array();
     foreach ($model_objects as $model_object) {
         $id = $model_object->ID();
         if (!$id) {
             if ($filter_out_empty_ids) {
                 continue;
             }
             if (WP_DEBUG) {
                 EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             }
         }
         $IDs[] = $id;
     }
     return $IDs;
 }
 /**
  *    _verify_critical_attendee_details_are_set
  *
  * @param string $form_input
  * @param string $input_value
  * @return boolean
  */
 private function _verify_critical_attendee_details_are_set_and_validate_email($form_input = '', $input_value = '')
 {
     if (empty($input_value)) {
         switch ($form_input) {
             case 'fname':
                 EE_Error::add_error(__('First Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                 return FALSE;
                 break;
             case 'lname':
                 EE_Error::add_error(__('Last Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                 return FALSE;
                 break;
             case 'email':
                 EE_Error::add_error(__('Email Address is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                 return FALSE;
                 break;
         }
     } else {
         if ($form_input === 'email') {
             // clean the email address
             $valid_email = sanitize_email($input_value);
             // check if it matches
             if ($input_value != $valid_email) {
                 // whoops!!!
                 EE_Error::add_error(__('Please enter a valid email address.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
 protected function _insert_update_cpt_item($post_id, $post)
 {
     $success = true;
     $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
     //for attendee updates
     if ($post->post_type = 'espresso_attendees' && !empty($attendee)) {
         //note we should only be UPDATING attendees at this point.
         $updated_fields = array('ATT_fname' => $this->_req_data['ATT_fname'], 'ATT_lname' => $this->_req_data['ATT_lname'], 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '');
         foreach ($updated_fields as $field => $value) {
             $attendee->set($field, $value);
         }
         $success = $attendee->save();
         $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array());
         foreach ($attendee_update_callbacks as $a_callback) {
             if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
                 throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback));
             }
         }
     }
     if ($success === FALSE) {
         EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
 }
 /**
  * Message triggers for manual payment applied by admin
  * @param  bool     $success incoming success value
  * @param  EE_Payment $payment EE_payment object
  * @return bool              success/fail
  */
 public static function process_admin_payment($success = TRUE, EE_Payment $payment)
 {
     //we need to get the transaction object
     $transaction = $payment->transaction();
     if ($transaction instanceof EE_Transaction) {
         $data = array($transaction, $payment);
         $message_type = self::_get_payment_message_type($payment->STS_ID());
         //if payment amount is less than 0 then switch to payment_refund message type.
         $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
         //if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
         $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type;
         self::_load_controller();
         //verify this message type is present and active.  If it isn't then no message is sent.
         $active_mts = self::$_EEMSG->get_active_message_types();
         $message_type = in_array($message_type, $active_mts) ? $message_type : false;
         if ($message_type) {
             $success = self::$_EEMSG->send_message($message_type, $data);
             if (!$success) {
                 EE_Error::add_error(__('Something went wrong and the payment confirmation was NOT resent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             }
         } else {
             EE_Error::add_error(__('The message type for the status of this payment is not active or does not exist, so no notification was sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     }
     return $success;
 }
Ejemplo n.º 26
0
 /**
  * _incompatible_addon_error
  *
  * @access public
  * @return void
  */
 private function _incompatible_addon_error()
 {
     // get array of classes hooking into here
     $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons');
     if (!empty($class_names)) {
         $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso');
         $msg .= '<ul>';
         foreach ($class_names as $class_name) {
             $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name) . '</b></li>';
         }
         $msg .= '</ul>';
         $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso');
         // save list of incompatible addons to wp-options for later use
         add_option('ee_incompatible_addons', $class_names, '', 'no');
         if (is_admin()) {
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
         }
     }
 }
 /**
  * 		_update_country_settings
  *
  * 		@access 	protected
  * 		@return 		void
  */
 protected function _update_country_settings()
 {
     //		EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     // grab the country ISO code
     $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : FALSE;
     if (!$CNT_ISO) {
         EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return;
     }
     $cols_n_values = array();
     $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : FALSE;
     $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : NULL;
     $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : NULL;
     $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD';
     $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar';
     $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars';
     $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$';
     $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : TRUE;
     $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2;
     $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.';
     $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ',';
     $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : NULL;
     $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : FALSE;
     $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : FALSE;
     // allow filtering of country data
     $cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values);
     //EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     // where values
     $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
     // run the update
     $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
     //		global $wpdb;
     //		echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$success : ' . $success . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== FALSE) {
         // allow filtering of states data
         $states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states']);
         //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         // loop thru state data ( looks like : states[75][STA_name] )
         foreach ($states as $STA_ID => $state) {
             $cols_n_values = array('CNT_ISO' => $CNT_ISO, 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), 'STA_name' => sanitize_text_field($state['STA_name']), 'STA_active' => (bool) absint($state['STA_active']));
             // where values
             $where_cols_n_values = array(array('STA_ID' => $STA_ID));
             // run the update
             $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
             if ($success !== FALSE) {
                 do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values);
             }
         }
     }
     // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
     if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) {
         EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
         EE_Registry::instance()->CFG->update_espresso_config();
     }
     $this->_redirect_after_action($success, 'Countries', 'updated', array('action' => 'country_settings', 'country' => $CNT_ISO));
 }
 private function _insert_category($update = FALSE)
 {
     $cat_id = $update ? $this->_req_data['VEN_CAT_ID'] : '';
     $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
     $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
     $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
     if (empty($category_name)) {
         $msg = __('You must add a name for the category.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     $term_args = array('name' => $category_name, 'description' => $category_desc, 'parent' => $category_parent);
     $insert_ids = $update ? wp_update_term($cat_id, 'espresso_venue_categories', $term_args) : wp_insert_term($category_name, 'espresso_venue_categories', $term_args);
     if (!is_array($insert_ids)) {
         $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
     } else {
         $cat_id = $insert_ids['term_id'];
         $msg = sprintf(__('The category %s was successfuly created', 'event_espresso'), $category_name);
         EE_Error::add_success($msg);
     }
     return $cat_id;
 }
 /**
  *    update_config'
  *
  * @access    public
  * @param bool $add_success
  * @param bool $add_error
  * @return bool success
  */
 public function update_config($add_success = FALSE, $add_error = TRUE)
 {
     do_action('AHEE__EE_Network_Config__update_config__begin', $this);
     //we have to compare existing saved config with config in memory because if there is no difference that means
     //that the method executed fine but there just was no update.  WordPress doesn't distinguish between false because
     //there were 0 records updated because of no change vs false because some error produced problems with the update.
     $original = get_site_option('ee_network_config');
     if ($original == $this) {
         return true;
     }
     // update
     $saved = update_site_option('ee_network_config', $this);
     do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved);
     // if config remains the same or was updated successfully
     if ($saved) {
         if ($add_success) {
             $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso');
             EE_Error::add_success($msg);
         }
         return TRUE;
     } else {
         if ($add_error) {
             $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso');
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
         }
         return FALSE;
     }
 }
 /**
  * add_subsections
  * Adds the listed subsections to the form section.
  * If $subsection_name_to_target is provided,
  * then new subsections are added before or after that subsection,
  * otherwise to the start or end of the entire subsections array.
  *
  * @param EE_Form_Section_Base[] $new_subsections                                                 array of new form subsections where keys are their names
  * @param string                 $subsection_name_to_target                                       an existing for section that $new_subsections should be added before or after
  *                                                                                                IF $subsection_name_to_target is null, then $new_subsections will be added to
  *                                                                                                the beginning or end of the entire subsections array
  * @param boolean                $add_before                                                      whether to add $new_subsections, before or after $subsection_name_to_target,
  *                                                                                                or if $subsection_name_to_target is null, before or after entire subsections array
  * @return void
  * @throws \EE_Error
  */
 public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true)
 {
     foreach ($new_subsections as $subsection_name => $subsection) {
         if (!$subsection instanceof EE_Form_Section_Base) {
             EE_Error::add_error(sprintf(__("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), get_class($subsection), $subsection_name, $this->name()));
             unset($new_subsections[$subsection_name]);
         }
     }
     $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before);
     /*$subsections_before = array();
     		if( $subsection_name_to_target ){
     			foreach( $this->_subsections as $subsection_name => $subsection ) {
     				if ( $add_before && $subsection_name == $subsection_name_to_target ) {
     					break;
     				}
     				$subsections_before[$subsection_name] = $subsection;
     				if ( ! $add_before && $subsection_name == $subsection_name_to_target ) {
     					break;
     				}
     			}
     			$subsections_after = array_diff_key($this->_subsections, $subsections_before);
     			$this->_subsections = array_merge($subsections_before,$new_subsections,$subsections_after);
     		}else{
     			if( $add_before ) {
     				//add before nothing, meaning nothing should be after it
     				//don't use array_merge because keys might be numeric and we want to preserve their keys
     				foreach( $new_subsections as $key => $subsection ){
     					$this->_subsections[ $key ] = $subsection;
     				}
     			}else{
     				//add after nothing, meaning nothing should be before it
     				//again don't use array_merge because we want
     				foreach( $this->_subsections as $key => $subsection ) {
     					$new_subsections[ $key ] = $subsection;
     				}
     				$this->_subsections = $new_subsections;
     			}
     		}*/
     if ($this->_construction_finalized) {
         foreach ($this->_subsections as $name => $subsection) {
             $subsection->_construct_finalize($this, $name);
         }
     }
 }