本文整理汇总了PHP中EEM_Registration类的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Registration类的具体用法?PHP EEM_Registration怎么用?PHP EEM_Registration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EEM_Registration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _create_checkin_checkout_object
/**
* Toggles whether the user is checked in or not.
*
* @param \WP_REST_Request $request
* @return \WP_Error|\WP_REST_Response
*/
protected function _create_checkin_checkout_object(\WP_REST_Request $request)
{
$reg_id = $request->get_param('REG_ID');
$dtt_id = $request->get_param('DTT_ID');
$force = $request->get_param('force');
if ($force == 'true') {
$force = true;
} else {
$force = false;
}
$reg = \EEM_Registration::instance()->get_one_by_ID($reg_id);
if (!$reg instanceof \EE_Registration) {
return $this->send_response(new \WP_Error('rest_registration_toggle_checkin_invalid_id', sprintf(__('You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso'), $reg_id), array('status' => 422)));
}
if (!\EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
return $this->send_response(new \WP_Error('rest_user_cannot_toggle_checkin', sprintf(__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), $reg_id), array('status' => 403)));
}
$success = $reg->toggle_checkin_status($dtt_id, !$force);
if ($success === false) {
//rely on EE_Error::add_error messages to have been added to give more data about hwy it failed
return $this->send_response(new \WP_Error('rest_toggle_checkin_failed', __('Registration checkin failed. Please see additional error data.', 'event_espresso')));
}
$checkin = \EEM_Checkin::instance()->get_one(array(array('REG_ID' => $reg_id, 'DTT_ID' => $dtt_id), 'order_by' => array('CHK_timestamp' => 'DESC')));
if (!$checkin instanceof \EE_Checkin) {
return $this->send_response(new \WP_Error('rest_toggle_checkin_error', sprintf(__('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso'), $reg_id, $dtt_id)));
}
$requested_version = $this->get_requested_version($request->get_route());
$get_request = new \WP_REST_Request('GET', \EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID());
$get_request->set_url_params(array('id' => $checkin->ID()));
return Read::handle_request_get_one($get_request);
}
示例2: datetime_checkin_stati
/**
* Calculates the checkin status for each datetime this registration has access to
*
* @param array $wpdb_row
* @param \WP_REST_Request $request
* @param Base $controller
* @return int
* @throws \EE_Error
*/
public static function datetime_checkin_stati($wpdb_row, $request, $controller)
{
if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) {
$reg = \EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']);
} else {
$reg = null;
}
if (!$reg instanceof \EE_Registration) {
throw new \EE_Error(sprintf(__('Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso'), $wpdb_row['Registration.REG_ID'], print_r($wpdb_row, true)));
}
$datetime_ids = \EEM_Datetime::instance()->get_col(array(array('Ticket.TKT_ID' => $reg->ticket_ID())));
$checkin_stati = array();
foreach ($datetime_ids as $datetime_id) {
$status = $reg->check_in_status_for_datetime($datetime_id);
switch ($status) {
case \EE_Registration::checkin_status_out:
$status_pretty = 'OUT';
break;
case \EE_Registration::checkin_status_in:
$status_pretty = 'IN';
break;
case \EE_Registration::checkin_status_never:
default:
$status_pretty = 'NEVER';
break;
}
$checkin_stati[$datetime_id] = $status_pretty;
}
return $checkin_stati;
}
示例3: test_get_minimum_where_conditions_during_query
/**
* @group 9179
*/
public function test_get_minimum_where_conditions_during_query()
{
$this->new_model_obj_with_dependencies('Registration', array('REG_deleted' => true));
$this->new_model_obj_with_dependencies('Registration', array('REG_deleted' => false));
//count using the default where conditions, which excludes the deleted one
$this->assertEquals(1, EEM_Registration::instance()->count());
//count using the MINIMUM where conditions, which INCLUDES the deleted one
$this->assertEquals(2, EEM_Registration::instance()->count(array('default_where_conditions' => 'minimum')));
}
示例4: convert_data_from_persistent_storage
/**
* Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
* can be sent into this method and converted back into the format used for instantiating with this data handler.
*
* @param $data
*
* @return mixed
*/
public static function convert_data_from_persistent_storage($data)
{
$registration = null;
//$data['Registration'] could be either an ID (back compat) or a registration object (prepped using old system).
if (isset($data['Registration'])) {
$registration = $data['Registration'] instanceof EE_Registration ? $data['Registration'] : EEM_Registration::instance()->get_one_by_ID($data['Registration']);
}
$prepped_data = array(0 => $registration, 1 => isset($data['filter']) ? $data['filter'] : null);
return $prepped_data;
}
示例5: _get_data_from_request
/**
* This returns the data property according to what is expected from the request.
* @param $id
* @throws EE_Error
* @return mixed (whatever the data is returned from the message type).
*/
protected function _get_data_from_request($id)
{
//get the EE_Registration from the token
/** @type EE_Registration $registration */
$registration = EEM_Registration::instance()->get_one(array(array('REG_url_link' => $this->token)));
//if no registration then bail early.
if (!$registration instanceof EE_Registration) {
throw new EE_Error(__('Unable to complete the request because the token is invalid.', 'event_espresso'));
}
return $this->_get_data_to_use($registration, $id);
}
示例6: test_delete_registrations_with_no_transaction
/**
* @group 7965
*/
function test_delete_registrations_with_no_transaction()
{
$deletable_count = 5;
$safe_count = 8;
$this->factory->registration->create_many($deletable_count, array('TXN_ID' => 0));
for ($i = 0; $i < $safe_count; $i++) {
$this->new_model_obj_with_dependencies('Registration');
}
$deleted = EEM_Registration::instance()->delete_registrations_with_no_transaction();
$this->assertEquals($deletable_count, $deleted);
}
示例7: _remove_unbillable_registrations
/**
* _calculate_billable_ticket_quantities_from_registrations
* compiles a list of EE_Tickets for each event in the passed array
*
* @access protected
* @param EE_Registration[] $registrations
* @return mixed
*/
protected function _remove_unbillable_registrations($registrations = array())
{
if (!empty($registrations)) {
// these reg statuses require payment (if event is not free)
$requires_payment = EEM_Registration::reg_statuses_that_allow_payment();
foreach ($registrations as $key => $registration) {
if (!$registration instanceof EE_Registration) {
continue;
}
// are we billing for this registration at this moment ?
if (!$registration->owes_monies_and_can_pay($requires_payment) && !($registration->final_price() == 0 && in_array($registration->status_ID(), $requires_payment))) {
// not billable. remove it
unset($registrations[$key]);
}
}
}
return $registrations;
}
示例8: __construct
/**
* Adds a relationship to Term_Taxonomy for each CPT_Base
* @param string $timezone
* @return EEM_Event
*/
protected function __construct($timezone = null)
{
EE_Registry::instance()->load_model('Registration');
$this->singular_item = __('Event', 'event_espresso');
$this->plural_item = __('Events', 'event_espresso');
// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
// to remove Postponed events from the frontend, copy the following filter to your functions.php file
// add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
// to remove Sold Out events from the frontend, copy the following filter to your functions.php file
// add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
$this->_custom_stati = apply_filters('AFEE__EEM_Event__construct___custom_stati', array(EEM_Event::cancelled => array('label' => __('Cancelled', 'event_espresso'), 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE)), EEM_Event::postponed => array('label' => __('Postponed', 'event_espresso'), 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE)), EEM_Event::sold_out => array('label' => __('Sold Out', 'event_espresso'), 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE))));
$this->_tables = array('Event_CPT' => new EE_Primary_Table('posts', 'ID'), 'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'));
$this->_fields = array('Event_CPT' => array('EVT_ID' => new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')), 'EVT_name' => new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''), 'EVT_desc' => new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''), 'EVT_slug' => new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''), 'EVT_created' => new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, current_time('timestamp')), 'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''), 'EVT_modified' => new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), TRUE, current_time('timestamp')), 'EVT_wp_user' => new EE_Integer_Field('post_author', __('Wordpress User ID', 'event_espresso'), FALSE, 1), 'parent' => new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), TRUE), 'EVT_order' => new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1), 'post_type' => new EE_WP_Post_Type_Field('espresso_events'), 'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati)), 'Event_Meta' => array('EVTM_ID' => new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE), 'EVT_ID_fk' => new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE), 'EVT_display_desc' => new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1), 'EVT_display_ticket_selector' => new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1), 'EVT_visible_on' => new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, current_time('timestamp')), 'EVT_additional_limit' => new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10), 'EVT_default_registration_status' => new EE_Enum_Text_Field('EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, EEM_Registration::status_id_pending_payment, EEM_Registration::reg_status_array()), 'EVT_member_only' => new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE), 'EVT_phone' => new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE), 'EVT_allow_overflow' => new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE), 'EVT_timezone_string' => new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE), 'EVT_external_URL' => new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE), 'EVT_donations' => new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE)));
$this->_model_relations = array('Registration' => new EE_Has_Many_Relation(), 'Datetime' => new EE_Has_Many_Relation(), 'Question_Group' => new EE_HABTM_Relation('Event_Question_Group'), 'Venue' => new EE_HABTM_Relation('Event_Venue'), 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), 'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'), 'Attendee' => new EE_HABTM_Relation('Registration'));
$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_events', 'EVTM_ID');
parent::__construct($timezone);
}
示例9: test_generate_restrictions__basic_and_others
function test_generate_restrictions__basic_and_others()
{
global $current_user;
$current_user = $this->factory->user->create_and_get();
//currently registrations have the 'ee_read_registrations' and 'ee_read_others_registrations' permissions
//if that changes, this will need to be updated
$generator = new EE_Restriction_Generator_Protected();
$generator->_construct_finalize(EEM_Registration::instance(), EEM_Base::caps_read);
$restrictions = $generator->generate_restrictions();
foreach ($restrictions as $default_where_conditions) {
$default_where_conditions->_finalize_construct(EEM_Registration::instance());
}
$this->assertArrayHasKey('ee_read_registrations', $restrictions);
$this->assertInstanceOf('EE_Return_None_Where_Conditions', $restrictions['ee_read_registrations']);
$this->assertArrayHasKey('ee_read_others_registrations', $restrictions);
$this->assertInstanceOf('EE_Default_Where_Conditions', $restrictions['ee_read_others_registrations']);
$this->assertEquals(array(EEM_Registration::instance()->wp_user_field_name() => get_current_user_id()), $restrictions['ee_read_others_registrations']->get_default_where_conditions());
$this->assertEquals(2, count($restrictions));
}
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:19,代码来源:EE_Restriciton_Generator_Protected_Test.php
示例10: test_fix_reg_final_price_rounding_issue
/**
* @group 8193
*/
function test_fix_reg_final_price_rounding_issue()
{
$txn = $this->new_model_obj_with_dependencies('Transaction', array('TXN_total' => 2.99));
$regs = array();
for ($i = 0; $i < 3; $i++) {
$regs[] = $this->new_model_obj_with_dependencies('Registration', array('REG_final_price' => 1, 'TXN_ID' => $txn->ID()));
}
//ok so there's a 1 cent difference. The REG_final_price_sum should be 1 cent more than the transaction total
$reg_final_price_sum = EEM_Registration::instance()->sum(array(array('TXN_ID' => $txn->ID())), 'REG_final_price');
$this->assertEquals($txn->total() + 0.01, $reg_final_price_sum);
$reg_processor = EE_Registry::instance()->load_class('Registration_Processor');
$success = $reg_processor->fix_reg_final_price_rounding_issue($txn);
$this->assertTrue($success);
$new_reg_final_price_sum = EEM_Registration::instance()->sum(array(array('TXN_ID' => $txn->ID())), 'REG_final_price');
$this->assertEquals($txn->total(), $new_reg_final_price_sum);
//specifically, the first reg should now be $0.99, but the others should still be $1 each
$this->assertEquals(0.99, $regs[0]->final_price());
$this->assertEquals(1, $regs[1]->final_price());
$this->assertEquals(1, $regs[2]->final_price());
}
示例11: generate_registration_months_dropdown
/**
* generates a month/year dropdown selector for all registrations matching the given criteria. Typically used for list table filter.
* @param string $cur_date any currently selected date can be entered here.
* @param string $status Registration status
* @param integer $evt_category Event Category ID if the Event Category filter is selected
* @return string html
*/
public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
{
$_where = array();
if (!empty($status)) {
$_where['STS_ID'] = $status;
}
if ($evt_category > 0) {
$_where['Event.Term_Taxonomy.term_id'] = $evt_category;
}
$regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
//setup vals for select input helper
$options = array(0 => array('text' => __('Select a Month/Year', 'event_espresso'), 'id' => ''));
foreach ($regdtts as $regdtt) {
$date = $regdtt->reg_month . ' ' . $regdtt->reg_year;
$options[] = array('text' => $date, 'id' => $date);
}
return self::select_input('month_range', $options, $cur_date, '', 'wide');
}
示例12: update_sold
/**
* Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime (via the tickets).
* into account
* @return int
*/
public function update_sold()
{
$count_regs_for_this_datetime = EEM_Registration::instance()->count(array(array('STS_ID' => EEM_Registration::status_id_approved, 'Ticket.Datetime.DTT_ID' => $this->ID(), 'REG_deleted' => 0)));
$this->set('DTT_sold', $count_regs_for_this_datetime);
$this->save();
return $count_regs_for_this_datetime;
}
示例13: process_shortcode
/**
* process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
*
*
*
* [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event.
* [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event.
* [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime.
* [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket.
* [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees
* regardless of status. Note default is to only return approved attendees
* [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar. Otherwise if this is set
* then return gravatar for email address given.
*
* Note: because of the relationship between event_id, ticket_id, and datetime_id. If more than one of those params
* is included then preference is given to the following:
* - event_id is used whenever its present and any others are ignored.
* - if no event_id then datetime is used whenever its present and any others are ignored.
* - otherwise ticket_id is used if present.
*
* @access public
* @param array $attributes
* @return string
*/
public function process_shortcode($attributes = array())
{
//load helpers
EE_Registry::instance()->load_helper('Event_View');
EE_Registry::instance()->load_helper('Template');
// merge in any attributes passed via fallback shortcode processor
$attributes = array_merge((array) $attributes, (array) $this->_attributes);
//set default attributes
$default_shortcode_attributes = array('event_id' => null, 'datetime_id' => null, 'ticket_id' => null, 'status' => EEM_Registration::status_id_approved, 'show_gravatar' => false);
// allow the defaults to be filtered
$default_shortcode_attributes = apply_filters('EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', $default_shortcode_attributes);
// grab attributes and merge with defaults, then extract
$attributes = array_merge($default_shortcode_attributes, $attributes);
$template_args = array('contacts' => array(), 'event' => null, 'datetime' => null, 'ticket' => null, 'show_gravatar' => $attributes['show_gravatar']);
//start setting up the query for the contacts
$query = array();
$error = false;
//what event?
if (empty($attributes['event_id']) && empty($attributes['datetime_id']) && empty($attributes['ticket_id'])) {
//seems like is_espresso_event_single() isn't working as expected. So using alternate method.
if (is_single() && is_espresso_event()) {
$event = EEH_Event_View::get_event();
if ($event instanceof EE_Event) {
$template_args['event'] = $event;
$query[0]['Registration.EVT_ID'] = $event->ID();
}
} else {
//try getting the earliest active event if none then get the
$events = EEM_Event::instance()->get_active_events(array('limit' => 1, 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')));
$events = empty($events) ? EEM_Event::instance()->get_upcoming_events(array('limit' => 1, 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'))) : $events;
$event = reset($events);
if ($event instanceof EE_Event) {
$query[0]['Registration.EVT_ID'] = $event->ID();
$template_args['event'] = $event;
}
}
} elseif (!empty($attributes['event_id'])) {
$event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
if ($event instanceof EE_Event) {
$query[0]['Registration.EVT_ID'] = $attributes['event_id'];
$template_args['event'] = $event;
} else {
$error = true;
}
}
//datetime?
if (!empty($attributes['datetime_id']) && empty($attributes['event_id'])) {
$datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
if ($datetime instanceof EE_Datetime) {
$query[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id'];
$query['default_where_conditions'] = 'this_model_only';
$template_args['datetime'] = $datetime;
$template_args['event'] = $datetime->event();
} else {
$error = true;
}
}
//ticket?just
if (!empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) {
$ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
if ($ticket instanceof EE_Ticket) {
$query[0]['Registration.TKT_ID'] = $attributes['ticket_id'];
$template_args['ticket'] = $ticket;
$template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime ? $ticket->first_datetime()->event() : null;
} else {
$error = true;
}
}
//status
$reg_status_array = EEM_Registration::reg_status_array();
if ($attributes['status'] != 'all' && isset($reg_status_array[$attributes['status']])) {
$query[0]['Registration.STS_ID'] = $attributes['status'];
}
$query['group_by'] = array('ATT_ID');
$query['order_by'] = apply_filters('FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC'));
//if we have NO query where conditions, then there was an invalid parameter or the shortcode was used incorrectly
//.........这里部分代码省略.........
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:101,代码来源:EES_Espresso_Event_Attendees.shortcode.php
示例14: spaces_remaining_for_sale
/**
* This returns the total remaining spaces for sale on this event.
*
* ############################
* VERY IMPORTANT FOR DEVELOPERS:
* While included here, this method is still being tested internally, so its signature and behaviour COULD change. While
* this comment block is in place, usage is at your own risk and know that it may change in future builds.
* ############################
*
* @uses EE_Event::total_available_spaces()
* @return float|int (EE_INF is returned as float)
*/
public function spaces_remaining_for_sale()
{
//first get total available spaces including consideration for tickets that have already sold.
$spaces_available = $this->total_available_spaces(true);
//if total available = 0, then exit right away because that means everything is expired.
if ($spaces_available === 0) {
return 0;
}
//subtract total approved registrations from spaces available to get how many are remaining.
$spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true);
$spaces_remaining = $spaces_available - $spots_taken;
return $spaces_remaining > 0 ? $spaces_remaining : 0;
}
示例15: run
/**
* This runs when the msg_url_trigger route has initiated.
*
* @since 4.5.0
* @param WP $WP
* @throws EE_Error
* @return void
*/
public function run($WP)
{
$sending_messenger = EE_Registry::instance()->REQ->is_set('snd_msgr') ? EE_Registry::instance()->REQ->get('snd_msgr') : '';
$generating_messenger = EE_Registry::instance()->REQ->is_set('gen_msgr') ? EE_Registry::instance()->REQ->get('gen_msgr') : '';
$message_type = EE_Registry::instance()->REQ->is_set('message_type') ? EE_Registry::instance()->REQ->get('message_type') : '';
$context = EE_Registry::instance()->REQ->is_set('context') ? EE_Registry::instance()->REQ->get('context') : '';
$token = EE_Registry::instance()->REQ->is_set('token') ? EE_Registry::instance()->REQ->get('token') : '';
$data_id = EE_Registry::instance()->REQ->is_set('id') ? (int) EE_Registry::instance()->REQ->get('id') : 0;
//verify the needed params are present.
if (empty($sending_messenger) || empty($generating_messenger) || empty($message_type) || empty($context) || empty($token)) {
EE_Error::add_error(__('The request for the "msg_url_trigger" route has a malformed url.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
return;
}
//get the registration: the token will always be the unique REG_url_link saved with a registration. We use that to make sure we retrieve the correct data for the given registration.
$registration = EEM_Registration::instance()->get_one(array(array('REG_url_link' => $token)));
//if no registration then bail early.
if (!$registration instanceof EE_Registration) {
EE_Error::add_error(__('Unable to complete the request because the token is invalid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
return;
}
//ensure controller is loaded
self::_load_controller();
// attempt to process message
try {
// retrieve the data via the handler
// Depending on the context and the message type data handler, the data_id will correspond to the specific data handler item we need to retrieve for specific messages
// (i.e. a specific payment or specific refund).
$data = $this->_get_messages_data_from_url($generating_messenger, $message_type, $registration, $data_id, $context);
//make sure we drop generating messenger if both sending and generating are the same.
$generating_messenger = $sending_messenger != $generating_messenger ? $generating_messenger : NULL;
//now we can trigger the actual sending of the message via the message type.
self::$_EEMSG->send_message($message_type, $data, $sending_messenger, $generating_messenger, $context);
} catch (EE_Error $e) {
$error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso');
// add specific message for developers if WP_DEBUG in on
$error_msg .= '||' . $e->getMessage();
EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
}
}