Guest User

modified registration page

a guest
Jan 15th, 2013
13
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
  2. do_action('action_hook_espresso_log', __FILE__, 'FILE LOADED', '');
  3. //As of version 3.0.17
  4. //This is a logic file for displaying a registration form for an event on a page. This file will do all of the backend data retrieval functions.
  5. //There should be a copy of this file in your wp-content/uploads/espresso/ folder.
  6. //Note: This entire function can be overridden using the "Custom Files" addon
  7. if (!function_exists('register_attendees')) {
  8.  
  9. function register_attendees($single_event_id = NULL, $event_id_sc =0, $reg_form_only = false) {
  10. //Declare the $data object
  11. $data = (object)array( 'event' => NULL );
  12.  
  13. do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
  14. //Run code for the seating chart addon
  15. if ( function_exists('espresso_seating_version') ){
  16. do_action('ee_seating_chart_css');
  17. do_action('ee_seating_chart_js');
  18. do_action('ee_seating_chart_flush_expired_seats');
  19. }
  20.  
  21. global $wpdb, $org_options;
  22.  
  23. if (isset($_REQUEST['ee']) && $_REQUEST['ee'] != '') {
  24. $_REQUEST['event_id'] = $_REQUEST['ee'];
  25. }
  26.  
  27. $event_id = $event_id_sc != '0' ? $event_id_sc : $_REQUEST['event_id'];
  28.  
  29. if (!empty($_REQUEST['event_id_time'])) {
  30. $pieces = explode('|', $_REQUEST['event_id_time'], 3);
  31. $event_id = $pieces[0];
  32. $start_time = $pieces[1];
  33. $time_id = $pieces[2];
  34. $time_selected = true;
  35. }
  36.  
  37. //The following variables are used to get information about your organization
  38. $event_page_id = $org_options['event_page_id'];
  39. $Organization = stripslashes_deep($org_options['organization']);
  40. $Organization_street1 = $org_options['organization_street1'];
  41. $Organization_street2 = $org_options['organization_street2'];
  42. $Organization_city = $org_options['organization_city'];
  43. $Organization_state = $org_options['organization_state'];
  44. $Organization_zip = $org_options['organization_zip'];
  45. $contact = $org_options['contact_email'];
  46. $registrar = $org_options['contact_email'];
  47. $currency_format = isset($org_options['currency_format']) ? $org_options['currency_format'] : '';
  48.  
  49. $message = $org_options['message'];
  50.  
  51. //Build event queries
  52. $sql = "SELECT e.*, ese.start_time, ese.end_time ";
  53. if ( isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ) {
  54. $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 ";
  55. }
  56. $sql .= " FROM " . EVENTS_DETAIL_TABLE . " e ";
  57. $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id ";
  58.  
  59. if ( isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ) {
  60. $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 ";
  61. }
  62. $sql.= " WHERE e.is_active='Y' ";
  63. $sql.= " AND e.event_status != 'D' ";
  64.  
  65. //Get the ID of a single event
  66. if ($single_event_id != NULL) {
  67. //If a single event needs to be displayed, get its ID
  68. $sql .= " AND event_identifier = '" . $single_event_id . "' ";
  69. } else {
  70. $sql.= " AND e.id = '" . $event_id . "' LIMIT 0,1";
  71. }
  72.  
  73. //Support for diarise
  74. if (!empty($_REQUEST['post_event_id'])) {
  75. $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . ' e';
  76. $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id ";
  77. $sql .= " WHERE post_id = '" . $_REQUEST['post_event_id'] . "' ";
  78. $sql .= " LIMIT 0,1";
  79. }
  80.  
  81. $data->event = $wpdb->get_row( $wpdb->prepare( $sql, NULL ), OBJECT);
  82. $num_rows = $wpdb->num_rows;
  83.  
  84. //Build the registration page
  85. if ($num_rows > 0) {
  86.  
  87. //These are the variables that can be used throughout the registration page
  88. //foreach ($events as $event) {
  89. global $this_event_id;
  90. $event_id = $data->event->id;
  91. $this_event_id = $event_id;
  92.  
  93. $event_name = stripslashes_deep($data->event->event_name);
  94. $event_desc = stripslashes_deep($data->event->event_desc);
  95. $display_desc = $data->event->display_desc;
  96. if ( $reg_form_only == true )
  97. $display_desc = "N";
  98.  
  99. $display_reg_form = $data->event->display_reg_form;
  100. $event_address = $data->event->address;
  101. $event_address2 = $data->event->address2;
  102. $event_city = $data->event->city;
  103. $event_state = $data->event->state;
  104. $event_zip = $data->event->zip;
  105. $event_country = $data->event->country;
  106. $event_description = stripslashes_deep($data->event->event_desc);
  107. $event_identifier = $data->event->event_identifier;
  108. $event_cost = isset($data->event->event_cost) ? $data->event->event_cost : "0.00";
  109. $member_only = $data->event->member_only;
  110. $reg_limit = $data->event->reg_limit;
  111. $allow_multiple = $data->event->allow_multiple;
  112. $start_date = $data->event->start_date;
  113. $end_date = $data->event->end_date;
  114. $allow_overflow = $data->event->allow_overflow;
  115. $overflow_event_id = $data->event->overflow_event_id;
  116.  
  117. //Venue details
  118. $venue_title = $data->event->venue_title;
  119. $venue_url = $data->event->venue_url;
  120. $venue_image = $data->event->venue_image;
  121. $venue_phone = $data->event->venue_phone;
  122. $venue_address = '';
  123. $venue_address2 = '';
  124. $venue_city = '';
  125. $venue_state = '';
  126. $venue_zip = '';
  127. $venue_country = '';
  128.  
  129. global $event_meta;
  130. $event_meta = unserialize($data->event->event_meta);
  131.  
  132. //Venue information
  133. if ($org_options['use_venue_manager'] == 'Y') {
  134. $event_address = $data->event->venue_address;
  135. $event_address2 = $data->event->venue_address2;
  136. $event_city = $data->event->venue_city;
  137. $event_state = $data->event->venue_state;
  138. $event_zip = $data->event->venue_zip;
  139. $event_country = $data->event->venue_country;
  140.  
  141. //Leaving these variables intact, just in case people wnat to use them
  142. $venue_title = $data->event->venue_name;
  143. $venue_address = $data->event->venue_address;
  144. $venue_address2 = $data->event->venue_address2;
  145. $venue_city = $data->event->venue_city;
  146. $venue_state = $data->event->venue_state;
  147. $venue_zip = $data->event->venue_zip;
  148. $venue_country = $data->event->venue_country;
  149. global $venue_meta;
  150. $add_venue_meta = array(
  151. 'venue_title' => $data->event->venue_name,
  152. 'venue_address' => $data->event->venue_address,
  153. 'venue_address2' => $data->event->venue_address2,
  154. 'venue_city' => $data->event->venue_city,
  155. 'venue_state' => $data->event->venue_state,
  156. 'venue_country' => $data->event->venue_country,
  157. );
  158. $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) : '';
  159. //print_r($venue_meta);
  160. }
  161.  
  162. $virtual_url = stripslashes_deep($data->event->virtual_url);
  163. $virtual_phone = stripslashes_deep($data->event->virtual_phone);
  164.  
  165. //Address formatting
  166. $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 : '');
  167.  
  168. //Google map link creation
  169. $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'));
  170.  
  171. $question_groups = unserialize($data->event->question_groups);
  172. $reg_start_date = $data->event->registration_start;
  173. $reg_end_date = $data->event->registration_end;
  174. $today = date("Y-m-d");
  175. if (isset($data->event->timezone_string) && $data->event->timezone_string != '') {
  176. $timezone_string = $data->event->timezone_string;
  177. } else {
  178. $timezone_string = get_option('timezone_string');
  179. if (!isset($timezone_string) || $timezone_string == '') {
  180. $timezone_string = 'America/New_York';
  181. }
  182. }
  183.  
  184. $t = time();
  185. $today = date_at_timezone("Y-m-d H:i A", $timezone_string, $t);
  186. //echo event_date_display($today, get_option('date_format'). ' ' .get_option('time_format')) . ' ' . $timezone_string;
  187. //echo espresso_ddtimezone_simple();
  188. $reg_limit = $data->event->reg_limit;
  189. $additional_limit = $data->event->additional_limit;
  190.  
  191.  
  192.  
  193. //If the coupon code system is intalled then use it
  194. $use_coupon_code = $data->event->use_coupon_code;
  195.  
  196. //If the groupon code addon is installed, then use it
  197. $use_groupon_code = $data->event->use_groupon_code;
  198.  
  199. //Set a default value for additional limit
  200. if ($additional_limit == '') {
  201. $additional_limit = '5';
  202. }
  203.  
  204. $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees
  205. $available_spaces = get_number_of_attendees_reg_limit($event_id, 'available_spaces'); //Gets a count of the available spaces
  206. $number_available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces'); //Gets the number of available spaces
  207. //echo $number_available_spaces;
  208.  
  209.  
  210. global $all_meta;
  211. $all_meta = array(
  212. 'event_id' => $event_id,
  213. 'event_name' => stripslashes_deep($event_name),
  214. 'event_desc' => stripslashes_deep($event_desc),
  215. 'event_address' => $event_address,
  216. 'event_address2' => $event_address2,
  217. 'event_city' => $event_city,
  218. 'event_state' => $event_state,
  219. 'event_zip' => $event_zip,
  220. 'event_country' => $event_country,
  221. 'venue_title' => $venue_title,
  222. 'venue_address' => $venue_address,
  223. 'venue_address2' => $venue_address2,
  224. 'venue_city' => $venue_city,
  225. 'venue_state' => $venue_state,
  226. 'venue_country' => $venue_country,
  227. 'location' => $location,
  228. 'is_active' => $data->event->is_active,
  229. 'event_status' => $data->event->event_status,
  230. 'contact_email' => empty($data->event->alt_email) ? $org_options['contact_email'] : $data->event->alt_email,
  231. 'start_time' => empty($data->event->start_time) ? '' : $data->event->start_time,
  232. 'end_time' => empty($data->event->end_time) ? '' : $data->event->end_time,
  233. 'registration_startT' => $data->event->registration_startT,
  234. 'registration_start' => $data->event->registration_start,
  235. 'registration_endT' => $data->event->registration_endT,
  236. 'registration_end' => $data->event->registration_end,
  237. 'start_date' => event_espresso_no_format_date($start_date, get_option('date_format')),
  238. 'end_date' => event_date_display($end_date, get_option('date_format')),
  239. 'google_map_link' => $google_map_link,
  240. );
  241.  
  242. //print_r($all_meta);
  243. //This function gets the status of the event.
  244. $is_active = array();
  245. $is_active = event_espresso_get_is_active(0, $all_meta);
  246. //echo '<p>'.print_r(event_espresso_get_is_active($event_id, $all_meta)).'</p>';;
  247.  
  248. if ($org_options['use_captcha'] == 'Y' && empty($_REQUEST['edit_details'])) {
  249. ?>
  250. <script type="text/javascript">
  251. var RecaptchaOptions = {
  252. theme : '<?php echo $org_options['recaptcha_theme'] == '' ? 'red' : $org_options['recaptcha_theme']; ?>',
  253. lang : '<?php echo $org_options['recaptcha_language'] == '' ? 'en' : $org_options['recaptcha_language']; ?>'
  254. };
  255. </script>
  256. <?php
  257. }
  258. //This is the start of the registration form. This is where you can start editing your display.
  259. //(Shows the regsitration form if enough spaces exist)
  260. if ($num_attendees >= $reg_limit) {
  261. ?>
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. <?php
  269.  
  270. // This is from the registration_page_display.php file and is here so when an event is full it still displays the event details.
  271. ?>
  272.  
  273. <?php
  274. $ui_corner = 'ui-corner-all';
  275. ?>
  276.  
  277. <h3 class="event_title ui-widget-header ui-corner-top" id="event_title-<?php echo $event_id; ?>">
  278. <?php echo $event_name ?> <?php echo $is_active['status'] == 'EXPIRED' ? ' - <span class="expired_event">Event Expired</span>' : ''; ?> <?php echo $is_active['status'] == 'PENDING' ? ' - <span class="expired_event">Event is Pending</span>' : ''; ?> <?php echo $is_active['status'] == 'DRAFT' ? ' - <span class="expired_event">Event is a Draft</span>' : ''; ?>
  279. </h3>
  280.  
  281. <?php
  282. $ui_corner = 'ui-corner-bottom';
  283. ?>
  284. <div class="event_espresso_form_wrapper event-data-display ui-widget-content <?php echo $ui_corner ?>">
  285. <?php //Featured image
  286. echo apply_filters('filter_hook_espresso_display_featured_image', $event_id, !empty($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : '');?>
  287.  
  288. <p class="section-title">
  289. <?php _e('Description:', 'event_espresso') ?>
  290. </p>
  291.  
  292. <?php echo do_shortcode("[ESPRESSO_VENUE show_map_image='true' map_image_wrapper='google-map' map_w='650' map_h='300']"); ?>
  293. <div class="event_description clearfix">
  294. <?php echo espresso_format_content($event_desc); //Code to show the actual description. The Wordpress function "wpautop" adds formatting to your description. ?>
  295.  
  296. </div>
  297.  
  298.  
  299.  
  300.  
  301.  
  302. <div class="espresso_event_full event-display-boxes" id="espresso_event_full-<?php echo $event_id; ?>">
  303. <h3 class="event_title"><?php //echo stripslashes_deep($event_name) ?></h3>
  304. <div class="event-messages">
  305. <p class="event_full"><strong><?php _e('We are sorry but this event has reached the maximum number of attendees!', 'event_espresso'); ?></strong></p>
  306. <p class="event_full"><strong><?php _e('Please check back in the event someone cancels.', 'event_espresso'); ?></strong></p>
  307. <p class="num_attendees"><?php _e('Current Number of Attendees:', 'event_espresso'); ?> <?php echo $num_attendees ?></p>
  308. </div>
  309. <?php
  310. $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.
  311. if (($num_attendees >= $reg_limit) && ($allow_overflow == 'Y' && $overflow_event_id != 0)) {
  312. ?>
  313. <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>
  314. <?php } ?>
  315. </div>
  316.  
  317. <?php
  318. } else {
  319. $member_options = get_option('events_member_settings');
  320. //echo "<pre>".print_r($member_options,true)."</pre>";
  321. //If enough spaces exist then show the form
  322. //Check to see if the Members plugin is installed.
  323. if ( function_exists('espresso_members_installed') && espresso_members_installed() == true && !is_user_logged_in() && ($member_only == 'Y' || $member_options['member_only_all'] == 'Y') ) {
  324. event_espresso_user_login();
  325. } else {
  326. //Serve up the registration form
  327. //As of version 3.0.17 the registration details have been moved to registration_form.php
  328. require('registration_page_display.php');
  329. }
  330. }//End if ($num_attendees >= $reg_limit) (Shows the regsitration form if enough spaces exist)
  331. } else {//If there are no results from the query, display this message
  332. echo '<h3>'.__('This event has expired or is no longer available.', 'event_espresso').'</h3>';
  333. }
  334.  
  335. echo espresso_registration_footer();
  336.  
  337. //Check to see how many database queries were performed
  338. //echo '<p>Database Queries: ' . get_num_queries() .'</p>';
  339. }
  340.  
  341. }
RAW Paste Data