function register_attendees($single_event_id = NULL, $event_id_sc = 0, $reg_form_only = false) { //Declare the $data object $data = (object) array('event' => NULL); do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); //Run code for the seating chart addon if (function_exists('espresso_seating_version')) { do_action('ee_seating_chart_css'); do_action('ee_seating_chart_js'); do_action('ee_seating_chart_flush_expired_seats'); } global $wpdb, $org_options; if (isset($_REQUEST['ee']) && $_REQUEST['ee'] != '') { $_REQUEST['event_id'] = $_REQUEST['ee']; } $event_id = $event_id_sc != '0' ? $event_id_sc : $_REQUEST['event_id']; if (!empty($_REQUEST['event_id_time'])) { $pieces = explode('|', $_REQUEST['event_id_time'], 3); $event_id = $pieces[0]; $start_time = $pieces[1]; $time_id = $pieces[2]; $time_selected = true; } //The following variables are used to get information about your organization $event_page_id = $org_options['event_page_id']; $Organization = stripslashes_deep($org_options['organization']); $Organization_street1 = $org_options['organization_street1']; $Organization_street2 = $org_options['organization_street2']; $Organization_city = $org_options['organization_city']; $Organization_state = $org_options['organization_state']; $Organization_zip = $org_options['organization_zip']; $contact = $org_options['contact_email']; $registrar = $org_options['contact_email']; $currency_format = isset($org_options['currency_format']) ? $org_options['currency_format'] : ''; $message = $org_options['message']; //Build event queries $sql = "SELECT e.*, ese.start_time, ese.end_time "; if (isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y') { $sql .= ", v.name venue_name, v.address venue_address, v.address2 venue_address2, v.city venue_city, v.state venue_state, v.zip venue_zip, v.country venue_country, v.meta venue_meta "; } $sql .= " FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id "; if (isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y') { $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " r ON r.event_id = e.id LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = r.venue_id "; } $sql .= " WHERE e.is_active='Y' "; $sql .= " AND e.event_status != 'D' "; //Get the ID of a single event if ($single_event_id != NULL) { //If a single event needs to be displayed, get its ID $sql .= " AND event_identifier = '" . $single_event_id . "' "; } else { $sql .= " AND e.id = '" . $event_id . "' LIMIT 0,1"; } //Support for diarise if (!empty($_REQUEST['post_event_id'])) { $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . ' e'; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id "; $sql .= " WHERE post_id = '" . $_REQUEST['post_event_id'] . "' "; $sql .= " LIMIT 0,1"; } $data->event = $wpdb->get_row($wpdb->prepare($sql, NULL), OBJECT); $num_rows = $wpdb->num_rows; //Build the registration page if ($num_rows > 0) { //These are the variables that can be used throughout the registration page //foreach ($events as $event) { global $this_event_id; $event_id = $data->event->id; $this_event_id = $event_id; $event_name = stripslashes_deep($data->event->event_name); $event_desc = stripslashes_deep($data->event->event_desc); $display_desc = $data->event->display_desc; if ($reg_form_only == true) { $display_desc = "N"; } $display_reg_form = $data->event->display_reg_form; $event_address = $data->event->address; $event_address2 = $data->event->address2; $event_city = $data->event->city; $event_state = $data->event->state; $event_zip = $data->event->zip; $event_country = $data->event->country; $event_description = stripslashes_deep($data->event->event_desc); $event_identifier = $data->event->event_identifier; $event_cost = isset($data->event->event_cost) ? $data->event->event_cost : "0.00"; $member_only = $data->event->member_only; $reg_limit = $data->event->reg_limit; $allow_multiple = $data->event->allow_multiple; $start_date = $data->event->start_date; $end_date = $data->event->end_date; $allow_overflow = $data->event->allow_overflow; $overflow_event_id = $data->event->overflow_event_id; //Venue details $venue_title = $data->event->venue_title; $venue_url = $data->event->venue_url; $venue_image = $data->event->venue_image; $venue_phone = $data->event->venue_phone; $venue_address = ''; $venue_address2 = ''; $venue_city = ''; $venue_state = ''; $venue_zip = ''; $venue_country = ''; global $event_meta; $event_meta = unserialize($data->event->event_meta); //Venue information if ($org_options['use_venue_manager'] == 'Y') { $event_address = $data->event->venue_address; $event_address2 = $data->event->venue_address2; $event_city = $data->event->venue_city; $event_state = $data->event->venue_state; $event_zip = $data->event->venue_zip; $event_country = $data->event->venue_country; //Leaving these variables intact, just in case people wnat to use them $venue_title = $data->event->venue_name; $venue_address = $data->event->venue_address; $venue_address2 = $data->event->venue_address2; $venue_city = $data->event->venue_city; $venue_state = $data->event->venue_state; $venue_zip = $data->event->venue_zip; $venue_country = $data->event->venue_country; global $venue_meta; $add_venue_meta = array('venue_title' => $data->event->venue_name, 'venue_address' => $data->event->venue_address, 'venue_address2' => $data->event->venue_address2, 'venue_city' => $data->event->venue_city, 'venue_state' => $data->event->venue_state, 'venue_country' => $data->event->venue_country); $venue_meta = isset($data->event->venue_meta) && $data->event->venue_meta != '' && (isset($add_venue_meta) && $add_venue_meta != '') ? array_merge(unserialize($data->event->venue_meta), $add_venue_meta) : ''; //print_r($venue_meta); } $virtual_url = stripslashes_deep($data->event->virtual_url); $virtual_phone = stripslashes_deep($data->event->virtual_phone); //Address formatting $location = (!empty($event_address) ? $event_address : '') . (!empty($event_address2) ? '<br />' . $event_address2 : '') . (!empty($event_city) ? '<br />' . $event_city : '') . (!empty($event_state) ? ', ' . $event_state : '') . (!empty($event_zip) ? '<br />' . $event_zip : '') . (!empty($event_country) ? '<br />' . $event_country : ''); //Google map link creation $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country, 'text' => 'Map and Directions', 'type' => 'text')); $question_groups = unserialize($data->event->question_groups); $reg_start_date = $data->event->registration_start; $reg_end_date = $data->event->registration_end; $today = date("Y-m-d"); if (isset($data->event->timezone_string) && $data->event->timezone_string != '') { $timezone_string = $data->event->timezone_string; } else { $timezone_string = get_option('timezone_string'); if (!isset($timezone_string) || $timezone_string == '') { $timezone_string = 'America/New_York'; } } $t = time(); $today = date_at_timezone("Y-m-d H:i A", $timezone_string, $t); //echo event_date_display($today, get_option('date_format'). ' ' .get_option('time_format')) . ' ' . $timezone_string; //echo espresso_ddtimezone_simple(); $reg_limit = $data->event->reg_limit; $additional_limit = $data->event->additional_limit; //If the coupon code system is intalled then use it $use_coupon_code = $data->event->use_coupon_code; //If the groupon code addon is installed, then use it $use_groupon_code = $data->event->use_groupon_code; //Set a default value for additional limit if ($additional_limit == '') { $additional_limit = '5'; } $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees $available_spaces = get_number_of_attendees_reg_limit($event_id, 'available_spaces'); //Gets a count of the available spaces $number_available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces'); //Gets the number of available spaces //echo $number_available_spaces; global $all_meta; $all_meta = array('event_id' => $event_id, 'event_name' => stripslashes_deep($event_name), 'event_desc' => stripslashes_deep($event_desc), 'event_address' => $event_address, 'event_address2' => $event_address2, 'event_city' => $event_city, 'event_state' => $event_state, 'event_zip' => $event_zip, 'event_country' => $event_country, 'venue_title' => $venue_title, 'venue_address' => $venue_address, 'venue_address2' => $venue_address2, 'venue_city' => $venue_city, 'venue_state' => $venue_state, 'venue_country' => $venue_country, 'location' => $location, 'is_active' => $data->event->is_active, 'event_status' => $data->event->event_status, 'contact_email' => empty($data->event->alt_email) ? $org_options['contact_email'] : $data->event->alt_email, 'start_time' => empty($data->event->start_time) ? '' : $data->event->start_time, 'end_time' => empty($data->event->end_time) ? '' : $data->event->end_time, 'registration_startT' => $data->event->registration_startT, 'registration_start' => $data->event->registration_start, 'registration_endT' => $data->event->registration_endT, 'registration_end' => $data->event->registration_end, 'start_date' => event_espresso_no_format_date($start_date, get_option('date_format')), 'end_date' => event_date_display($end_date, get_option('date_format')), 'google_map_link' => $google_map_link); //print_r($all_meta); //This function gets the status of the event. $is_active = array(); $is_active = event_espresso_get_is_active(0, $all_meta); //echo '<p>'.print_r(event_espresso_get_is_active($event_id, $all_meta)).'</p>';; if ($org_options['use_captcha'] == 'Y' && empty($_REQUEST['edit_details'])) { ?> <script type="text/javascript"> var RecaptchaOptions = { theme : '<?php echo $org_options['recaptcha_theme'] == '' ? 'red' : $org_options['recaptcha_theme']; ?> ', lang : '<?php echo $org_options['recaptcha_language'] == '' ? 'en' : $org_options['recaptcha_language']; ?> ' }; </script> <?php } //This is the start of the registration form. This is where you can start editing your display. //(Shows the regsitration form if enough spaces exist) if ($num_attendees >= $reg_limit) { ?> <div class="espresso_event_full event-display-boxes" id="espresso_event_full-<?php echo $event_id; ?> "> <h3 class="event_title"><?php echo stripslashes_deep($event_name); ?> </h3> <div class="event-messages"> <p class="event_full"><strong><?php _e('We are sorry but this event has reached the maximum number of attendees!', 'event_espresso'); ?> </strong></p> <p class="event_full"><strong><?php _e('Please check back in the event someone cancels.', 'event_espresso'); ?> </strong></p> <p class="num_attendees"><?php _e('Current Number of Attendees:', 'event_espresso'); ?> <?php echo $num_attendees; ?> </p> </div> <?php $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees. Please visit http://eventespresso.com/forums/?p=247 for available parameters for the get_number_of_attendees_reg_limit() function. if ($num_attendees >= $reg_limit && ($allow_overflow == 'Y' && $overflow_event_id != 0)) { ?> <p id="register_link-<?php echo $overflow_event_id; ?> " class="register-link-footer"><a class="a_register_link ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" id="a_register_link-<?php echo $overflow_event_id; ?> " href="<?php echo espresso_reg_url($overflow_event_id); ?> " title="<?php echo stripslashes_deep($event_name); ?> "><?php _e('Join Waiting List', 'event_espresso'); ?> </a></p> <?php } ?> </div> <?php } else { $member_options = get_option('events_member_settings'); //echo "<pre>".print_r($member_options,true)."</pre>"; //If enough spaces exist then show the form //Check to see if the Members plugin is installed. if (function_exists('espresso_members_installed') && espresso_members_installed() == true && !is_user_logged_in() && ($member_only == 'Y' || $member_options['member_only_all'] == 'Y')) { event_espresso_user_login(); } else { //Serve up the registration form //As of version 3.0.17 the registration details have been moved to registration_form.php require 'registration_page_display.php'; } } //End if ($num_attendees >= $reg_limit) (Shows the regsitration form if enough spaces exist) } else { //If there are no results from the query, display this message echo '<h3>' . __('This event has expired or is no longer available.', 'event_espresso') . '</h3>'; } echo espresso_registration_footer(); //Check to see how many database queries were performed //echo '<p>Database Queries: ' . get_num_queries() .'</p>'; }
function event_espresso_get_event_details($sql, $css_class = NULL, $allow_override = 0) { //echo $sql; global $wpdb, $org_options, $events_in_session; $multi_reg = false; if (function_exists('event_espresso_multi_reg_init')) { $multi_reg = true; } //echo 'This page is located in ' . get_option( 'upload_path' ); $event_page_id = $org_options['event_page_id']; $currency_symbol = isset($org_options['currency_symbol']) ? $org_options['currency_symbol'] : ''; $events = $wpdb->get_results($sql); $category_id = isset($wpdb->last_result[0]->id) ? $wpdb->last_result[0]->id : ''; $category_name = isset($wpdb->last_result[0]->category_name) ? $wpdb->last_result[0]->category_name : ''; $category_identifier = isset($wpdb->last_result[0]->category_identifier) ? $wpdb->last_result[0]->category_identifier : ''; $category_desc = isset($wpdb->last_result[0]->category_desc) ? html_entity_decode(wpautop($wpdb->last_result[0]->category_desc)) : ''; $display_desc = isset($wpdb->last_result[0]->display_desc) ? $wpdb->last_result[0]->display_desc : ''; if ($display_desc == 'Y') { echo '<p id="events_category_name-' . $category_id . '" class="events_category_name">' . stripslashes_deep($category_name) . '</p>'; echo espresso_format_content($category_desc); } //Debug //var_dump($events); foreach ($events as $event) { $event_id = $event->id; $event_name = $event->event_name; $event_desc = stripslashes_deep($event->event_desc); $event_identifier = $event->event_identifier; $active = $event->is_active; $registration_start = $event->registration_start; $registration_end = $event->registration_end; $start_date = $event->start_date; $end_date = $event->end_date; $reg_limit = $event->reg_limit; $event_address = $event->address; $event_address2 = $event->address2; $event_city = $event->city; $event_state = $event->state; $event_zip = $event->zip; $event_country = $event->country; $member_only = $event->member_only; $externalURL = $event->externalURL; $recurrence_id = $event->recurrence_id; $display_reg_form = $event->display_reg_form; $allow_overflow = $event->allow_overflow; $overflow_event_id = $event->overflow_event_id; $event_desc = array_shift(explode('<!--more-->', $event_desc)); global $event_meta; $event_meta = unserialize($event->event_meta); $event_meta['is_active'] = $event->is_active; $event_meta['event_status'] = $event->event_status; $event_meta['start_time'] = empty($event->start_time) ? '' : $event->start_time; $event_meta['start_date'] = $event->start_date; $event_meta['registration_start'] = $event->registration_start; $event_meta['registration_startT'] = $event->registration_startT; $event_meta['registration_end'] = $event->registration_end; $event_meta['registration_endT'] = $event->registration_endT; //Venue information if ($org_options['use_venue_manager'] == 'Y') { $event_address = empty($event->venue_address) ? '' : $event->venue_address; $event_address2 = empty($event->venue_address2) ? '' : $event->venue_address2; $event_city = empty($event->venue_city) ? '' : $event->venue_city; $event_state = empty($event->venue_state) ? '' : $event->venue_state; $event_zip = empty($event->venue_zip) ? '' : $event->venue_zip; $event_country = empty($event->venue_country) ? '' : $event->venue_country; //Leaving these variables intact, just in case people want to use them $venue_title = empty($event->venue_name) ? '' : $event->venue_name; $venue_address = $event_address; $venue_address2 = $event_address2; $venue_city = $event_city; $venue_state = $event_state; $venue_zip = $event_zip; $venue_country = $event_country; global $venue_meta; $add_venue_meta = array('venue_title' => $venue_title, 'venue_address' => $event_address, 'venue_address2' => $event_address2, 'venue_city' => $event_city, 'venue_state' => $event_state, 'venue_country' => $event_country); $venue_meta = !empty($event->venue_meta) && !empty($add_venue_meta) ? array_merge(unserialize($event->venue_meta), $add_venue_meta) : ''; //print_r($venue_meta); } //Address formatting $location = ($event_address != '' ? $event_address : '') . ($event_address2 != '' ? '<br />' . $event_address2 : '') . ($event_city != '' ? '<br />' . $event_city : '') . ($event_state != '' ? ', ' . $event_state : '') . ($event_zip != '' ? '<br />' . $event_zip : '') . ($event_country != '' ? '<br />' . $event_country : ''); //Google map link creation $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country, 'text' => 'Map and Directions', 'type' => 'text')); global $all_meta; $all_meta = array('event_name' => stripslashes_deep($event_name), 'event_desc' => stripslashes_deep($event_desc), 'event_address' => $event_address, 'event_address2' => $event_address2, 'event_city' => $event_city, 'event_state' => $event_state, 'event_zip' => $event_zip, 'is_active' => $event->is_active, 'event_status' => $event->event_status, 'start_time' => empty($event->start_time) ? '' : $event->start_time, 'registration_startT' => $event->registration_startT, 'registration_start' => $registration_start, 'registration_endT' => $event->registration_endT, 'registration_end' => $registration_end, 'is_active' => empty($is_active) ? '' : $is_active, 'event_country' => $event_country, 'start_date' => event_date_display($start_date, get_option('date_format')), 'end_date' => event_date_display($end_date, get_option('date_format')), 'time' => empty($event->start_time) ? '' : $event->start_time, 'google_map_link' => $google_map_link, 'price' => empty($event->event_cost) ? '' : $event->event_cost, 'event_cost' => empty($event->event_cost) ? '' : $event->event_cost); //Debug //echo '<p>'.print_r($all_meta).'</p>'; //These variables can be used with other the espresso_countdown, espresso_countup, and espresso_duration functions and/or any javascript based functions. //Warning: May cause additional database queries an should only be used for sites with a small amount of events. // $start_timestamp = espresso_event_time($event_id, 'start_timestamp'); //$end_timestamp = espresso_event_time($event_id, 'end_timestamp'); //This can be used in place of the registration link if you are usign the external URL feature $registration_url = $externalURL != '' ? $externalURL : espresso_reg_url($event_id); if (!is_user_logged_in() && get_option('events_members_active') == 'true' && $member_only == 'Y') { //Display a message if the user is not logged in. //_e('Member Only Event. Please ','event_espresso') . event_espresso_user_login_link() . '.'; } else { //Serve up the event list //As of version 3.0.17 the event list details have been moved to event_list_display.php if ($allow_override == 1) { //Uncomment to show active status array //print_r( event_espresso_get_is_active($event_id)); include 'event_list_display.php'; } else { switch (event_espresso_get_status($event_id)) { case 'NOT_ACTIVE': //Don't show the event //Uncomment the following two lines to show events that are not active and the active status array //print_r( event_espresso_get_is_active($event_id)); //include('event_list_display.php'); break; case 'PENDING': if (current_user_can('administrator') || function_exists('espresso_member_data') && espresso_can_view_event($event_id) == true) { //Uncomment to show active status array //print_r( event_espresso_get_is_active($event_id)); echo '<div class="pending_event">'; include 'event_list_display.php'; echo '</div>'; } break; default: //Uncomment to show active status array //print_r( event_espresso_get_is_active($event_id)); include 'event_list_display.php'; break; } } } } //Check to see how many database queries were performed //echo '<p>Database Queries: ' . get_num_queries() .'</p>'; espresso_registration_footer(); }
function event_espresso_get_event_details($attributes) { global $wpdb, $org_options, $events_in_session; $event_page_id = $org_options['event_page_id']; $currency_symbol = isset($org_options['currency_symbol']) ? $org_options['currency_symbol'] : ''; $ee_search = isset($_REQUEST['ee_search']) && $_REQUEST['ee_search'] == 'true' && isset($_REQUEST['ee_name']) && !empty($_REQUEST['ee_name']) ? true : false; $ee_search_string = isset($_REQUEST['ee_name']) && !empty($_REQUEST['ee_name']) ? sanitize_text_field($_REQUEST['ee_name']) : ''; //Check for Multi Event Registration $multi_reg = false; $category_name = ''; if (function_exists('event_espresso_multi_reg_init')) { $multi_reg = true; } $default_attributes = array('category_identifier' => NULL, 'staff_id' => NULL, 'allow_override' => 0, 'show_expired' => 'false', 'show_secondary' => 'false', 'show_deleted' => 'false', 'show_recurrence' => 'true', 'limit' => '0', 'order_by' => 'NULL', 'sort' => 'ASC', 'css_class' => 'NULL', 'current_page' => 1, 'events_per_page' => 50, 'num_page_links_to_display' => 10, 'use_wrapper' => true); // loop thru default atts foreach ($default_attributes as $key => $default_attribute) { // check if att exists if (!isset($attributes[$key])) { $attributes[$key] = $default_attribute; } } // now extract shortcode attributes extract($attributes); //Create the query $DISTINCT = $ee_search == true ? "DISTINCT" : ''; $sql = "SELECT {$DISTINCT} e.*, ese.start_time, ese.end_time, p.event_cost "; //Category sql $sql .= $category_identifier != NULL && !empty($category_identifier) ? ", c.category_name, c.category_desc, c.display_desc, c.category_identifier" : ''; //Venue sql isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= ", v.name venue_name, v.address venue_address, v.city venue_city, v.state venue_state, v.zip venue_zip, v.country venue_country, v.meta venue_meta " : ''; //Staff sql isset($org_options['use_personnel_manager']) && $org_options['use_personnel_manager'] == 'Y' ? $sql .= ", st.name staff_name " : ''; $sql .= " FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= $category_identifier != NULL && !empty($category_identifier) ? " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id " : ''; //Venue sql isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " vr ON vr.event_id = e.id LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = vr.venue_id " : ''; //Venue sql isset($org_options['use_personnel_manager']) && $org_options['use_personnel_manager'] == 'Y' ? $sql .= " LEFT JOIN " . EVENTS_PERSONNEL_REL_TABLE . " str ON str.event_id = e.id LEFT JOIN " . EVENTS_PERSONNEL_TABLE . " st ON st.id = str.person_id " : ''; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id= e.id "; $sql .= " LEFT JOIN " . EVENTS_PRICES_TABLE . " p ON p.event_id=e.id "; $sql .= " WHERE is_active = 'Y' "; //Category sql $sql .= $category_identifier !== NULL && !empty($category_identifier) ? " AND c.category_identifier = '" . $category_identifier . "' " : ''; //Staff sql $sql .= $staff_id !== NULL && !empty($staff_id) ? " AND st.id = '" . $staff_id . "' " : ''; $sql .= $show_expired == 'false' ? " AND (e.start_date >= '" . date('Y-m-d') . "' OR e.event_status = 'O' OR e.registration_end >= '" . date('Y-m-d') . "') " : ''; if ($show_expired == 'true') { $allow_override = 1; } //If using the [ESPRESSO_VENUE_EVENTS] shortcode $sql .= isset($use_venue_id) && $use_venue_id == true ? " AND v.id = '" . $venue_id . "' " : ''; $sql .= $show_secondary == 'false' ? " AND e.event_status != 'S' " : ''; $sql .= $show_deleted == 'false' ? " AND e.event_status != 'D' " : " AND e.event_status = 'D' "; if ($show_deleted == 'true') { $allow_override = 1; } //echo '<p>'.$order_by.'</p>'; $sql .= $show_recurrence == 'false' ? " AND e.recurrence_id = '0' " : ''; //Search query if ($ee_search) { // search for full original string within bracketed search options $sql .= " AND ( e.event_name LIKE '%{$ee_search_string}%' "; // array of common words that we don't want to waste time looking for $words_to_strip = array(' the ', ' a ', ' or ', ' and '); $words = str_replace($words_to_strip, ' ', $ee_search_string); // break words array into individual strings $words = explode(' ', $words); // search for each word as an OR statement foreach ($words as $word) { $sql .= " OR e.event_name LIKE '%{$word}%' "; } // close the search options $sql .= " ) "; } $sql .= " GROUP BY e.id "; $sql .= $order_by != 'NULL' ? " ORDER BY " . $order_by . " " . $sort . " " : " ORDER BY date(start_date), id ASC "; $sql .= $limit > 0 ? ' LIMIT 0, ' . $limit : ''; //echo $sql; //echo 'This page is located in ' . get_option( 'upload_path' ); $events = $wpdb->get_results($sql); $category_id = isset($wpdb->last_result[0]->id) ? $wpdb->last_result[0]->id : ''; $category_name = isset($wpdb->last_result[0]->category_name) ? $wpdb->last_result[0]->category_name : ''; $category_identifier = isset($wpdb->last_result[0]->category_identifier) ? $wpdb->last_result[0]->category_identifier : ''; $category_desc = isset($wpdb->last_result[0]->category_desc) ? html_entity_decode(wpautop($wpdb->last_result[0]->category_desc)) : ''; $display_desc = isset($wpdb->last_result[0]->display_desc) ? $wpdb->last_result[0]->display_desc : ''; $total_events = count($events); $total_pages = ceil($total_events / $events_per_page); $offset = ($current_page - 1) * $events_per_page; $events = array_slice($events, $offset, $events_per_page); //Debug //var_dump($events); if ($use_wrapper) { echo "<div id='event_wrapper'>"; } $page_link_ar = array(); foreach ($attributes as $key => $attribute) { if (!in_array($key, array('current_page', 'use_wrapper'))) { $page_link_ar[] = "{$key}=" . urlencode($attribute); } } $page_link = implode('&', $page_link_ar); echo "<div id='event_search_code' style='display:none;' data='{$page_link}'></div>"; //css_class='$css_class' allow_override='$allow_override' events_per_page='$events_per_page' num_page_links_to_display='$num_page_links_to_display'></div>"; echo "<div id='event_container_pagination' >"; if ($total_pages > 1) { $mid = ceil($num_page_links_to_display / 2); if ($num_page_links_to_display % 2 == 0) { $back = $mid; } else { $back = $mid - 1; } $start = $current_page - $back; if ($start < 1) { $start = 1; } $end = $start + $num_page_links_to_display; if ($end > $total_pages) { $end = $total_pages; } $prev = $current_page - 1; $prev_no_more = ''; if ($prev < 1) { $prev = 1; $prev_no_more = 'no_more'; } $next = $current_page + 1; $next_no_more = ''; if ($next > $total_pages) { $next = $total_pages; $next_no_more = 'no_more'; } $espresso_paginate = "<div class='page_navigation'>"; $espresso_paginate .= "<a href='#' current_page=1 class='event_paginate {$prev_no_more} ui-icon ui-icon-seek-first'><<</a>"; $espresso_paginate .= "<a href='#' current_page={$prev} class='event_paginate {$prev_no_more} ui-icon ui-icon-seek-prev'><</a>"; if ($start > 1) { $espresso_paginate .= "<span class='ellipse less'>...</span>"; } for ($i = $start; $i <= $end; $i++) { $active_page = ''; if ($i == $current_page) { $active_page = 'active_page'; } $espresso_paginate .= "<a class='page_link event_paginate {$active_page} ' current_page={$i} href='#' style='display: block; '>{$i}</a>"; } if ($end < $total_pages) { $espresso_paginate .= "<span class='ellipse more'>...</span>"; } $espresso_paginate .= "<a href='#' current_page={$next} class='event_paginate {$next_no_more} ui-icon ui-icon-seek-next'>></a>"; $espresso_paginate .= "<a href='#' current_page={$total_pages} class='event_paginate {$next_no_more} ui-icon ui-icon-seek-end'>>></a>"; $espresso_paginate .= "</div>"; } echo "<div id='event_content' class='event_content'>"; if (count($events) < 1) { //echo $sql; echo __('No events available...', 'event_espresso'); } if ($display_desc == 'Y') { echo '<p id="events_category_name-' . $category_id . '" class="events_category_name">' . stripslashes_deep($category_name) . '</p>'; echo espresso_format_content($category_desc); } foreach ($events as $event) { $event_id = $event->id; $event_name = $event->event_name; $event_desc = stripslashes_deep($event->event_desc); $event_identifier = $event->event_identifier; $active = $event->is_active; $registration_start = $event->registration_start; $registration_end = $event->registration_end; $start_date = $event->start_date; $end_date = $event->end_date; $reg_limit = $event->reg_limit; $event_address = $event->address; $event_address2 = $event->address2; $event_city = $event->city; $event_state = $event->state; $event_zip = $event->zip; $event_country = $event->country; $member_only = $event->member_only; $externalURL = $event->externalURL; $recurrence_id = $event->recurrence_id; $display_reg_form = $event->display_reg_form; $allow_overflow = $event->allow_overflow; $overflow_event_id = $event->overflow_event_id; $event_desc = array_shift(explode('<!--more-->', $event_desc)); global $event_meta; $event_meta = unserialize($event->event_meta); $event_meta['is_active'] = $event->is_active; $event_meta['event_status'] = $event->event_status; $event_meta['start_time'] = empty($event->start_time) ? '' : $event->start_time; $event_meta['start_date'] = $event->start_date; $event_meta['registration_start'] = $event->registration_start; $event_meta['registration_startT'] = $event->registration_startT; $event_meta['registration_end'] = $event->registration_end; $event_meta['registration_endT'] = $event->registration_endT; //Venue information if ($org_options['use_venue_manager'] == 'Y') { $event_address = empty($event->venue_address) ? '' : $event->venue_address; $event_address2 = empty($event->venue_address2) ? '' : $event->venue_address2; $event_city = empty($event->venue_city) ? '' : $event->venue_city; $event_state = empty($event->venue_state) ? '' : $event->venue_state; $event_zip = empty($event->venue_zip) ? '' : $event->venue_zip; $event_country = empty($event->venue_country) ? '' : $event->venue_country; //Leaving these variables intact, just in case people want to use them $venue_title = empty($event->venue_name) ? '' : $event->venue_name; $venue_address = $event_address; $venue_address2 = $event_address2; $venue_city = $event_city; $venue_state = $event_state; $venue_zip = $event_zip; $venue_country = $event_country; global $venue_meta; $add_venue_meta = array('venue_title' => $venue_title, 'venue_address' => $event_address, 'venue_address2' => $event_address2, 'venue_city' => $event_city, 'venue_state' => $event_state, 'venue_country' => $event_country); $venue_meta = !empty($event->venue_meta) && !empty($add_venue_meta) ? array_merge(unserialize($event->venue_meta), $add_venue_meta) : ''; //print_r($venue_meta); } //Address formatting $location = (!empty($event_address) ? $event_address : '') . (!empty($event_address2) ? '<br />' . $event_address2 : '') . (!empty($event_city) ? '<br />' . $event_city : '') . (!empty($event_state) ? ', ' . $event_state : '') . (!empty($event_zip) ? '<br />' . $event_zip : '') . (!empty($event_country) ? '<br />' . $event_country : ''); //Google map link creation $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country, 'text' => 'Map and Directions', 'type' => 'text')); global $all_meta; $all_meta = array('event_id' => $event_id, 'event_name' => stripslashes_deep($event_name), 'event_desc' => stripslashes_deep($event_desc), 'event_address' => $event_address, 'event_address2' => $event_address2, 'event_city' => $event_city, 'event_state' => $event_state, 'event_zip' => $event_zip, 'event_country' => $venue_country, 'venue_title' => $venue_title, 'venue_address' => $venue_address, 'venue_address2' => $venue_address2, 'venue_city' => $venue_city, 'venue_state' => $venue_state, 'venue_country' => $venue_country, 'location' => $location, 'is_active' => $event->is_active, 'event_status' => $event->event_status, 'contact_email' => empty($event->alt_email) ? $org_options['contact_email'] : $event->alt_email, 'start_time' => empty($event->start_time) ? '' : $event->start_time, 'registration_startT' => $event->registration_startT, 'registration_start' => $registration_start, 'registration_endT' => $event->registration_endT, 'registration_end' => $registration_end, 'is_active' => empty($is_active) ? '' : $is_active, 'event_country' => $event_country, 'start_date' => event_date_display($start_date, get_option('date_format')), 'end_date' => event_date_display($end_date, get_option('date_format')), 'time' => empty($event->start_time) ? '' : $event->start_time, 'start_time' => empty($event->start_time) ? '' : $event->start_time, 'end_time' => empty($event->end_time) ? '' : $event->end_time, 'google_map_link' => $google_map_link, 'price' => empty($event->event_cost) ? '' : $event->event_cost, 'event_cost' => empty($event->event_cost) ? '' : $event->event_cost); //Debug //echo '<p>'.print_r($all_meta).'</p>'; //These variables can be used with other the espresso_countdown, espresso_countup, and espresso_duration functions and/or any javascript based functions. //Warning: May cause additional database queries an should only be used for sites with a small amount of events. // $start_timestamp = espresso_event_time($event_id, 'start_timestamp'); //$end_timestamp = espresso_event_time($event_id, 'end_timestamp'); //This can be used in place of the registration link if you are usign the external URL feature $registration_url = $externalURL != '' ? $externalURL : espresso_reg_url($event_id); //Serve up the event list //As of version 3.0.17 the event list details have been moved to event_list_display.php if ($allow_override == 1) { //Uncomment to show active status array //print_r( event_espresso_get_is_active($event_id)); include 'event_list_display.php'; } else { switch (event_espresso_get_status($event_id)) { case 'NOT_ACTIVE': //Don't show the event //Uncomment the following two lines to show events that are not active and the active status array //print_r( event_espresso_get_is_active($event_id)); //include('event_list_display.php'); break; case 'PENDING': if (current_user_can('administrator') || function_exists('espresso_member_data') && espresso_can_view_event($event_id) == true) { //Uncomment to show active status array //print_r( event_espresso_get_is_active($event_id)); echo '<div class="pending_event">'; include 'event_list_display.php'; echo '</div>'; } break; default: //Uncomment to show active status array //print_r( event_espresso_get_is_active($event_id)); include 'event_list_display.php'; break; } } } echo "</div>"; echo "</div>"; if (isset($espresso_paginate)) { echo $espresso_paginate; // spit out the pagination links } if ($use_wrapper) { echo "</div>"; } //Check to see how many database queries were performed //echo '<p>Database Queries: ' . get_num_queries() .'</p>'; espresso_registration_footer(); }
function event_espresso_get_event_details($attributes) { //echo $sql; global $wpdb, $org_options, $events_in_session; $template_name = 'event_list_display.php'; $path = locate_template($template_name); $multi_reg = false; if (function_exists('event_espresso_multi_reg_init')) { $multi_reg = true; } $default_attributes = array('category_identifier' => NULL, 'staff_id' => NULL, 'allow_override' => 0, 'show_expired' => 'false', 'show_secondary' => 'false', 'show_deleted' => 'false', 'show_recurrence' => 'true', 'limit' => '0', 'order_by' => 'NULL', 'css_class' => 'NULL'); // loop thru default atts foreach ($default_attributes as $key => $default_attribute) { // check if att exists if (!isset($attributes[$key])) { $attributes[$key] = $default_attribute; } } // now extract shortcode attributes extract($attributes); $sql = "SELECT e.*, ese.start_time, ese.end_time, p.event_cost "; //Category sql $sql .= $category_identifier != NULL && !empty($category_identifier) ? ", c.category_name, c.category_desc, c.display_desc, c.category_identifier" : ''; //Venue sql isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= ", v.name venue_name, v.address venue_address, v.city venue_city, v.state venue_state, v.zip venue_zip, v.country venue_country, v.meta venue_meta " : ''; //Staff sql isset($org_options['use_personnel_manager']) && $org_options['use_personnel_manager'] == 'Y' ? $sql .= ", st.name staff_name " : ''; $sql .= " FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= $category_identifier != NULL && !empty($category_identifier) ? " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id " : ''; //Venue sql isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " vr ON vr.event_id = e.id LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = vr.venue_id " : ''; //Venue sql isset($org_options['use_personnel_manager']) && $org_options['use_personnel_manager'] == 'Y' ? $sql .= " LEFT JOIN " . EVENTS_PERSONNEL_REL_TABLE . " str ON str.event_id = e.id LEFT JOIN " . EVENTS_PERSONNEL_TABLE . " st ON st.id = str.person_id " : ''; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id= e.id "; $sql .= " LEFT JOIN " . EVENTS_PRICES_TABLE . " p ON p.event_id=e.id "; $sql .= " WHERE is_active = 'Y' "; //Category sql $sql .= $category_identifier !== NULL && !empty($category_identifier) ? " AND c.category_identifier = '" . $category_identifier . "' " : ''; //Staff sql $sql .= $staff_id !== NULL && !empty($staff_id) ? " AND st.id = '" . $staff_id . "' " : ''; $sql .= $show_expired == 'false' ? " AND (e.start_date >= '" . date('Y-m-d') . "' OR e.event_status = 'O' OR e.registration_end >= '" . date('Y-m-d') . "') " : ''; if ($show_expired == 'true') { $allow_override = 1; } //If using the [ESPRESSO_VENUE_EVENTS] shortcode $sql .= isset($use_venue_id) && $use_venue_id == true ? " AND v.id = '" . $venue_id . "' " : ''; $sql .= $show_secondary == 'false' ? " AND e.event_status != 'S' " : ''; $sql .= $show_deleted == 'false' ? " AND e.event_status != 'D' " : " AND e.event_status = 'D' "; if ($show_deleted == 'true') { $allow_override = 1; } $sql .= $show_recurrence == 'false' ? " AND e.recurrence_id = '0' " : ''; $sql .= " GROUP BY e.id "; $sql .= $order_by != 'NULL' ? " ORDER BY " . $order_by . " ASC " : " ORDER BY e.recurrence_id, date(start_date) ASC "; $sql .= $limit > 0 ? ' LIMIT 0, ' . $limit : ''; //echo $sql; $event_page_id = $org_options['event_page_id']; $currency_symbol = isset($org_options['currency_symbol']) ? $org_options['currency_symbol'] : ''; $events = $wpdb->get_results($sql); $category_id = isset($wpdb->last_result[0]->id) ? $wpdb->last_result[0]->id : ''; $category_name = isset($wpdb->last_result[0]->category_name) ? $wpdb->last_result[0]->category_name : ''; $category_identifier = isset($wpdb->last_result[0]->category_identifier) ? $wpdb->last_result[0]->category_identifier : ''; $category_desc = isset($wpdb->last_result[0]->category_desc) ? html_entity_decode(wpautop($wpdb->last_result[0]->category_desc)) : ''; $display_desc = isset($wpdb->last_result[0]->display_desc) ? $wpdb->last_result[0]->display_desc : ''; /* group recurring events */ $events_type_index = -1; $events_of_same_type = array(); $last_recurrence_id = null; /* end group recurring events */ if ($display_desc == 'Y') { echo '<p id="events_category_name-' . $category_id . '" class="events_category_name">' . stripslashes_deep($category_name) . '</p>'; echo wpautop($category_desc); } foreach ($events as $event) { $event_id = $event->id; $event_name = $event->event_name; $event_desc = stripslashes_deep($event->event_desc); $event_identifier = $event->event_identifier; $active = $event->is_active; $registration_start = $event->registration_start; $registration_end = $event->registration_end; $start_date = $event->start_date; $end_date = $event->end_date; $reg_limit = $event->reg_limit; $event_address = $event->address; $event_address2 = $event->address2; $event_city = $event->city; $event_state = $event->state; $event_zip = $event->zip; $event_country = $event->country; $member_only = $event->member_only; $externalURL = $event->externalURL; $recurrence_id = $event->recurrence_id; $display_reg_form = $event->display_reg_form; $allow_overflow = $event->allow_overflow; $overflow_event_id = $event->overflow_event_id; $event_desc = array_shift(explode('<!--more-->', $event_desc)); global $event_meta; $event_meta = unserialize($event->event_meta); $event_meta['is_active'] = $event->is_active; $event_meta['event_status'] = $event->event_status; $event_meta['start_time'] = empty($event->start_time) ? '' : $event->start_time; $event_meta['start_date'] = $event->start_date; $event_meta['registration_start'] = $event->registration_start; $event_meta['registration_startT'] = $event->registration_startT; $event_meta['registration_end'] = $event->registration_end; $event_meta['registration_endT'] = $event->registration_endT; //Venue information if ($org_options['use_venue_manager'] == 'Y') { $event_address = empty($event->venue_address) ? '' : $event->venue_address; $event_address2 = empty($event->venue_address2) ? '' : $event->venue_address2; $event_city = empty($event->venue_city) ? '' : $event->venue_city; $event_state = empty($event->venue_state) ? '' : $event->venue_state; $event_zip = empty($event->venue_zip) ? '' : $event->venue_zip; $event_country = empty($event->venue_country) ? '' : $event->venue_country; //Leaving these variables intact, just in case people want to use them $venue_title = empty($event->venue_name) ? '' : $event->venue_name; $venue_address = $event_address; $venue_address2 = $event_address2; $venue_city = $event_city; $venue_state = $event_state; $venue_zip = $event_zip; $venue_country = $event_country; global $venue_meta; $add_venue_meta = array('venue_title' => $venue_title, 'venue_address' => $event_address, 'venue_address2' => $event_address2, 'venue_city' => $event_city, 'venue_state' => $event_state, 'venue_country' => $event_country); $venue_meta = !empty($event->venue_meta) && !empty($add_venue_meta) ? array_merge(unserialize($event->venue_meta), $add_venue_meta) : ''; //print_r($venue_meta); } //Address formatting $location = ($event_address != '' ? $event_address : '') . ($event_address2 != '' ? '<br />' . $event_address2 : '') . ($event_city != '' ? '<br />' . $event_city : '') . ($event_state != '' ? ', ' . $event_state : '') . ($event_zip != '' ? '<br />' . $event_zip : '') . ($event_country != '' ? '<br />' . $event_country : ''); //Google map link creation $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country, 'text' => 'Map and Directions', 'type' => 'text')); global $all_meta; $all_meta = array('event_name' => stripslashes_deep($event_name), 'event_desc' => stripslashes_deep($event_desc), 'event_address' => $event_address, 'event_address2' => $event_address2, 'event_city' => $event_city, 'event_state' => $event_state, 'event_zip' => $event_zip, 'is_active' => $event->is_active, 'event_status' => $event->event_status, 'start_time' => empty($event->start_time) ? '' : $event->start_time, 'registration_startT' => $event->registration_startT, 'registration_start' => $registration_start, 'registration_endT' => $event->registration_endT, 'registration_end' => $registration_end, 'is_active' => empty($is_active) ? '' : $is_active, 'event_country' => $event_country, 'start_date' => event_date_display($start_date, get_option('date_format')), 'end_date' => event_date_display($end_date, get_option('date_format')), 'time' => empty($event->start_time) ? '' : $event->start_time, 'google_map_link' => $google_map_link, 'price' => empty($event->event_cost) ? '' : $event->event_cost, 'event_cost' => empty($event->event_cost) ? '' : $event->event_cost); //Debug //echo '<p>'.print_r($all_meta).'</p>'; //These variables can be used with other the espresso_countdown, espresso_countup, and espresso_duration functions and/or any javascript based functions. //Warning: May cause additional database queries an should only be used for sites with a small amount of events. // $start_timestamp = espresso_event_time($event_id, 'start_timestamp'); //$end_timestamp = espresso_event_time($event_id, 'end_timestamp'); //This can be used in place of the registration link if you are using the external URL feature $registration_url = $externalURL != '' ? $externalURL : espresso_reg_url($event_id); if (!is_user_logged_in() && get_option('events_members_active') == 'true' && $member_only == 'Y') { //Display a message if the user is not logged in. //_e('Member Only Event. Please ','event_espresso') . event_espresso_user_login_link() . '.'; } else { //Serve up the event list //As of version 3.0.17 the event list details have been moved to event_list_display.php switch (event_espresso_get_status($event_id)) { case 'NOT_ACTIVE': //Don't show the event if any of the above are true break; default: /* skip secondary (waitlist) events */ $event_status = event_espresso_get_is_active($event_id); if ($event_status['status'] == 'SECONDARY') { break; } /* group recurring events */ $is_new_event_type = $last_recurrence_id == 0 || $last_recurrence_id != $recurrence_id; if ($is_new_event_type) { $events_type_index++; $events_of_same_type[$events_type_index] = array(); } $event_data = array('event_id' => $event_id, 'event_page_id' => $event_page_id, 'event_name' => $event_name, 'event_desc' => $event_desc, 'start_date' => $start_date, 'end_date' => $end_date, 'reg_limit' => $reg_limit, 'registration_url' => $registration_url, 'overflow_event_id' => $overflow_event_id); array_push($events_of_same_type[$events_type_index], $event_data); $last_recurrence_id = $recurrence_id; break; } } } /* group recurring events */ foreach ($events_of_same_type as $events_group) { if (empty($path)) { include $template_name; } else { include $path; } } /* end group recurring events */ //Check to see how many database queries were performed //echo '<p>Database Queries: ' . get_num_queries() .'</p>'; espresso_registration_footer(); }