/** * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send trigger * * @since 4.3.0 * * @param EE_Attendee[] $contacts an array of EE_Attendee objects * @param int $grp_id a specific message template group id. * @return void */ public static function send_newsletter_message($contacts, $grp_id) { //make sure mtp is id and set it in the EE_Request Handler later messages setup. EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); self::_load_controller(); self::$_EEMSG->send_message('newsletter', $contacts); }
/** * Retrieve and set the message preview for display. * * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. * @return void */ public function _preview_message($send = FALSE) { //first make sure we've got the necessary parameters if (!isset($this->_req_data['message_type']) || !isset($this->_req_data['messenger']) || !isset($this->_req_data['messenger']) || !isset($this->_req_data['GRP_ID'])) { EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); $MSG = new EE_messages(); //get the preview! $preview = $MSG->preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); if ($send) { return $preview; } //let's add a button to go back to the edit view $query_args = array('id' => $this->_req_data['GRP_ID'], 'context' => $this->_req_data['context'], 'action' => 'edit_message_template'); $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; //let's provide a helpful title for context $preview_title = sprintf(__('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular'])); //setup display of preview. $this->_admin_page_title = $preview_title; $this->_template_args['admin_page_content'] = $preview_button . '<br />' . stripslashes($preview); $this->_template_args['data']['force_json'] = TRUE; }
public function messages_metabox($event, $callback_args) { //let's get the active messengers (b/c messenger objects have the active message templates) //convert 'evt_id' to 'EVT_ID' $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID']) ? $this->_req_data['post'] : $this->_req_data['EVT_ID']; $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id']) ? $this->_req_data['evt_id'] : $this->_req_data['EVT_ID']; $EEM_controller = new EE_messages(); $active_messengers = $EEM_controller->get_active_messengers(); $tabs = array(); //empty messengers? //Note message types will always have at least one available because every messenger has a default message type associated with it (payment) if no other message types are selected. if (empty($active_messengers)) { $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'settings'), EE_MSG_ADMIN_URL); $error_msg = sprintf(__('There are no active messengers. So no notifications will go out for <strong>any</strong> events. You will want to %sActivate a Messenger%s.', 'event_espresso'), '<a href="' . $msg_activate_url . '">', '</a>'); $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; echo $error_content; echo $internal_content; return; } $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; //get content for active messengers foreach ($active_messengers as $name => $messenger) { //first check if there are any active message types for this messenger. $active_mts = $EEM_controller->get_active_message_types_per_messenger($name); if (empty($active_mts)) { continue; } $tcont = $messenger->get_messenger_admin_page_content('events', 'edit', array('event' => $event_id)); if (!empty($tcont)) { $tabs[$name] = $tcont; } } EE_Registry::instance()->load_helper('Tabbed_Content'); //we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. $tabbed_content = EEH_Tabbed_Content::display($tabs); if (is_wp_error($tabbed_content)) { $tabbed_content = $tabbed_content->get_error_message(); } $notices = '<div id="espresso-ajax-loading" class="ajax-loader-grey"> <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso') . '</span> </div><div class="ee-notices"></div>'; if (defined('DOING_AJAX')) { return $tabbed_content; } do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); }
/** * The purpose of this function is to return all installed message objects (messengers and message type regardless of whether they are ACTIVE or not) * @param string $type * @return array array consisting of installed messenger objects and installed message type objects. */ public static function get_installed_message_objects($type = 'all') { self::_set_autoloader(); //get all installed messengers and message_types $EE_MSG = new EE_messages(); $installed_message_objects = $EE_MSG->get_installed($type); return $installed_message_objects; }