/**
  * load_message_types
  * globs the supplied filepath and adds any found
  *
  * @param  string $folder
  * @throws \EE_Error
  */
 public function load_message_types_from_folder($folder = '')
 {
     //make sure autoloaders are set (fail-safe)
     EED_Messages::set_autoloaders();
     $folder = !empty($folder) ? $folder : EE_LIBRARIES . 'messages' . DS . 'message_type';
     $folder .= $folder[strlen($folder) - 1] != DS ? DS : '';
     // get all the files in that folder that end in ".class.php
     $filepaths = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', glob($folder . '*.class.php'));
     if (empty($filepaths)) {
         return;
     }
     foreach ((array) $filepaths as $file_path) {
         // extract filename from path
         $file_path = basename($file_path);
         // now remove any file extensions
         $message_type_class_name = substr($file_path, 0, strpos($file_path, '.'));
         //if this class name doesn't represent a message type class, then we just skip.
         if (strpos(strtolower($message_type_class_name), 'message_type') === false) {
             continue;
         }
         if (!class_exists($message_type_class_name)) {
             throw new EE_Error(sprintf(__('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'), $message_type_class_name, $file_path));
         }
         $this->_load_message_type(new $message_type_class_name());
     }
 }
 /**
  * constructor
  * @constructor
  * @access public
  * @return void
  */
 public function __construct($routing = TRUE)
 {
     //make sure MSG Template helper is loaded.
     EE_Registry::instance()->load_helper('MSG_Template');
     //make sure messages autoloader is running
     EED_Messages::set_autoloaders();
     parent::__construct($routing);
 }
 protected function _set_list_table_views_default()
 {
     //for notification related bulk actions we need to make sure only active messengers have an option.
     EED_Messages::set_autoloaders();
     $EEMSG = EE_Registry::instance()->load_lib('messages');
     $active_mts = $EEMSG->get_active_message_types();
     //key= bulk_action_slug, value= message type.
     $match_array = array('approve_registration' => 'registration', 'decline_registration' => 'declined_registration', 'pending_registration' => 'pending_approval', 'no_approve_registration' => 'not_approved_registration', 'cancel_registration' => 'cancelled_registration');
     /** setup reg status bulk actions **/
     $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
     if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
         $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso');
     }
     $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
     if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
         $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso');
     }
     $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
     if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
         $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso');
     }
     $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
     if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
         $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso');
     }
     $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
     if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
         $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso');
     }
     $this->_views = array('all' => array('slug' => 'all', 'label' => __('View All Registrations', 'event_espresso'), 'count' => 0, 'bulk_action' => array_merge($def_reg_status_actions, array('trash_registrations' => __('Trash Registrations', 'event_espresso')))), 'month' => array('slug' => 'month', 'label' => __('This Month', 'event_espresso'), 'count' => 0, 'bulk_action' => array_merge($def_reg_status_actions, array('trash_registrations' => __('Trash Registrations', 'event_espresso')))), 'today' => array('slug' => 'today', 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), 'count' => 0, 'bulk_action' => array_merge($def_reg_status_actions, array('trash_registrations' => __('Trash Registrations', 'event_espresso')))));
     if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) {
         $this->_views['incomplete'] = array('slug' => 'incomplete', 'label' => __('Incomplete', 'event_espresso'), 'count' => 0, 'bulk_action' => array('trash_registrations' => __('Trash Registrations', 'event_espresso')));
         $this->_views['trash'] = array('slug' => 'trash', 'label' => __('Trash', 'event_espresso'), 'count' => 0, 'bulk_action' => array('restore_registrations' => __('Restore Registrations', 'event_espresso'), 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso')));
     }
 }
 /**
  * load the active files needed (key word... NEEDED)
  * @param string $kind indicates what kind of files we are loading.
  * @param array $actives indicates what active types of the $kind are actually to be loaded.
  */
 private function _load_files($kind, $actives)
 {
     $active_names = array();
     $base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS;
     if (empty($actives)) {
         return false;
     }
     //make sure autoloaders are set (failsafe)
     EED_Messages::set_autoloaders();
     //make sure $actives is an array
     $actives = (array) $actives;
     EE_Registry::instance()->load_helper('File');
     foreach ($actives as $active) {
         $msg_name = 'EE_' . ucwords(str_replace(' ', '_', $active)) . '_' . $kind;
         $filename = $msg_name . '.class.php';
         $load_file = $base_path . DS . $filename;
         if (is_readable($load_file)) {
             require_once $load_file;
             $active_names[$active] = $msg_name;
         } else {
             $this->_unset_active($active, $kind);
             //set WP_Error
             return EE_Error::add_error(sprintf(__("Missing messages system file set as inactive: (%s) %s has been made inactive.", 'event_espresso'), $load_file, $msg_name), __FILE__, __FUNCTION__, __LINE__);
         }
     }
     return $active_names;
 }
 /**
  * load_messengers
  * globs the supplied filepath and adds any found
  *
  * @return array
  */
 public function load_active_messengers_from_db()
 {
     //make sure autoloaders are set (fail-safe)
     EED_Messages::set_autoloaders();
     $active_messengers = apply_filters('FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option('ee_active_messengers', array()));
     foreach ((array) $active_messengers as $active_messenger_classname => $active_messenger) {
         $this->_load_messenger($active_messenger);
     }
 }
 private static function _set_autoloader()
 {
     EED_Messages::set_autoloaders();
 }
 /**
  * @param bool $routing
  */
 public function __construct($routing = true)
 {
     //make sure messages autoloader is running
     EED_Messages::set_autoloaders();
     parent::__construct($routing);
 }
 /**
  * @deprecated 4.5.0
  */
 public static function set_autoloaders()
 {
     self::doing_it_wrong_call(__METHOD__);
     EED_Messages::set_autoloaders();
 }
 /**
  * this just returns and array of instantiated shortcode objects given an array of object refs
  *
  * @access private
  * @param $sc_refs
  * @throws EE_Error
  * @return array    an array of EE_Shortcode objects
  */
 private function _get_shortcode_objects($sc_refs)
 {
     $sc_objs = array();
     EED_Messages::set_autoloaders();
     foreach ($sc_refs as $shortcode_ref) {
         $ref = ucwords(str_replace('_', ' ', $shortcode_ref));
         $ref = str_replace(' ', '_', $ref);
         $classname = 'EE_' . $ref . '_Shortcodes';
         if (!class_exists($classname)) {
             $msg[] = __('Shortcode library loading fail.', 'event_espresso');
             $msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate shortcode library file name (minus the extension) in the "/library/shortcodes/" directory', 'event_espresso'), $classname);
             throw new EE_Error(implode('||', $msg));
         }
         $a = new ReflectionClass($classname);
         $sc_objs[] = $a->newInstance();
     }
     return $sc_objs;
 }