/** * Initializes the data from the incoming info. * @param array $info incoming data. * @param bool $attached Indicates whether the object was attached successfully. * @param EE_Message $message * @return array */ protected function _init_data($info, $attached, $message) { $data = array('test_send' => false, 'preview' => false, 'data_handler_class_name' => '', 'data' => array('MSG_generation_data' => array())); if (isset($info['preview'])) { $data['preview'] = $info['preview']; unset($info['preview']); } if (isset($info['test_send'])) { $data['test_send'] = $info['test_send']; unset($info['test_send']); } if (isset($info['data_handler_class_name'])) { $data['data_handler_class_name'] = $info['data_handler_class_name']; unset($info['data_handler_class_name']); } if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) { $generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array(); //if data isn't in $info...let's see if its available via the message object $generation_data = !$generation_data ? $message->get_generation_data() : $generation_data; //still empty then let's just use info $generation_data = !$generation_data ? $info : $generation_data; $data['data']['MSG_generation_data'] = $generation_data; } return $data; }
/** * @param EE_Message $message * @return string The timestamp when this message was last modified. */ public function column_modified(EE_Message $message) { return $message->modified(); }
/** * simply validates the incoming message object and then sets up the properties for the messenger * @param EE_Message $message * @throws EE_Error */ protected function _validate_and_setup(EE_Message $message) { $template_pack = $message->get_template_pack(); $variation = $message->get_template_pack_variation(); //verify we have the required template pack value on the $message object. if (!$template_pack instanceof EE_Messages_Template_Pack) { throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso')); } $this->_tmp_pack = $template_pack; $this->_variation = $variation ? $variation : 'default'; $template_fields = $this->get_template_fields(); foreach ($template_fields as $template => $value) { if ($template !== 'extra') { $column_value = $message->get_field_or_extra_meta('MSG_' . $template); $message_template_value = $column_value ? $column_value : null; $this->_set_template_value($template, $message_template_value); } } }
/** * This returns the url for triggering a in browser view of a specific EE_Message object. * @param EE_Message $message * @return string. */ public static function generate_browser_trigger(EE_Message $message) { $query_args = array('ee' => 'msg_browser_trigger', 'token' => $message->MSG_token()); return apply_filters('FHEE__EEH_MSG_Template__generate_browser_trigger', add_query_arg($query_args, site_url()), $message); }
/** * @deprecated 4.9.0 * @param EE_Message $message * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if * available. * Eg. Valid Messenger and Message Type: * array( * 'messenger' => new EE_Email_messenger(), * 'message_type' => new EE_Registration_Approved_message_type() * ) * Valid Messenger and Invalid Message Type: * array( * 'messenger' => new EE_Email_messenger(), * 'message_type' => null * ) */ public function validate_for_use(EE_Message $message) { // EE_messages has been deprecated $this->_class_is_deprecated(__FUNCTION__); return array('messenger' => $message->messenger_object(), 'message_type' => $message->message_type_object()); }
/** * This sets any necessary error messages on the message object and its status to failed. * @param EE_Message $message * @param array $error_messages the response from the messenger. */ protected function _set_error_message(EE_Message $message, $error_messages) { $error_messages = (array) $error_messages; if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { $notices = EE_Error::has_notices(); $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); if ($notices === 1) { $notices = EE_Error::get_vanilla_notices(); $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); $error_messages[] = implode("\n", $notices['errors']); } } if (count($error_messages) > 0) { $msg = __('Message was not executed successfully.', 'event_espresso'); $msg = $msg . "\n" . implode("\n", $error_messages); $message->set_error_message($msg); } }
/** * @access protected * @param \EE_Message $message * @param bool $new_instance Whether the message type was setup from the database (false) or not (true) * @return \EE_Message * @throws \EE_Error */ protected function _set_message_type(EE_Message $message, $new_instance = false) { $message_type = $this->_message_resource_manager->get_message_type($message->message_type()); if ($message_type instanceof EE_message_type) { $message->set_message_type_object($message_type, $new_instance); } return $message; }