Upgrade to Pro Version | Donate | Support Reporting features provide a list of events, list of attendees, and excel export. Version: 2.1.6 Author: Seth Shoultes Author URI: http://www.shoultes.net Contributors: Ben Dunkle http://field2.com - Icon Design - Thanks Ben!! Changes: 2.1.5 Somehow the other changes didn't take effect! 2.1.4 Removed some old code. 2.1.3 Fixed database security holes. 2.1.2 Minor fixes throughout. 2.1.1 Added the ability to copy/duplicate an event. Fixed a bug with the event questions/answers not showing in the Excel export. Added event titles to the event url's for better SEO. 2.1.0 Removed the events_organization database table, we are now using the native Wordpress options database table to store the organization settings. This has speeded up the regsistration process considerably. */ /* Copyright 2009 SETH SHOULTES (email: seth@smartwebutah.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Define static variables define("EVNT_RGR_PLUGINPATH", "/" . plugin_basename( dirname(__FILE__) ) . "/"); define("EVNT_RGR_PLUGINFULLURL", WP_PLUGIN_URL . EVNT_RGR_PLUGINPATH ); //Install/Update Tables when plugin is activated require("includes/database_install.php"); register_activation_hook(__FILE__,'events_data_tables_install'); //Event questions/options require("includes/event_form_config.php"); //Payment Page/PayPal Buttons - Used to display the payment options and the payment link in the email. Used with the {EVENTREGPAY} tag require("includes/paypal.class.php"); require("includes/payment_page.php"); //The calendar pop function require("includes/tc_calendar.php"); //Events Listing - Shows the events on your page. Used with the {EVENTREGIS} tag require("includes/get_event_details.php"); require("includes/display_all_events.php"); //List Attendees - Used with the {EVENTATTENDEES} tag require("includes/attendee_list.php"); //Widget - Display the list of events in your sidebar require("includes/widget.php"); //Admin Widget - Display event stats in your admin dashboard require("includes/event_regis_dashboard_widget.php"); //Payment processing - Used for onsite payment processing. Used with the {EVENTPAYPALTXN} tag require("includes/process_payments.php"); //Build the admin header for the plugin require("includes/admin_header.php"); add_action('admin_head', 'admin_register_head'); //Event Registration Subpage - Configure Organization require("includes/organization_config_mnu.php"); //Event Registration Subpage - Add/Delete/Edit Events require("includes/manage_events.php"); //Event Registration Subpage - View Attendees require("includes/event_registration_reports.php"); require("includes/edit_attendee_record.php"); //require("includes/admin_list_attendees.php"); //Event Registration Subpage - Enter Attendee Payments require("includes/admin_reports.php"); require("includes/admin_process_payments.php"); require("includes/list_attendee_payments.php"); require("includes/enter_attendee_payments.php"); //Event Registration Subpage - Plugin Support require("includes/admin_event_categories.php"); require("includes/event_regis_categories.php"); //Event Registration Subpage - Plugin Support require("includes/admin_support.php"); //Main form events page require("includes/event_register_attendees.php"); //Event Registration Main Admin Page function event_regis_main_mnu(){ /* The following functions are what I wish to add to the main menu page 1. Display current count of attendees for active event (show event name, description and id)- shows by default */ organization_config_mnu(); } /** * Add a settings link to the Plugins page, so people can go straight from the plugin page to the * settings page. */ function event_regis_filter_plugin_actions( $links, $file ){ // Static so we don't call plugin_basename on every plugin row. static $this_plugin; if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__); if ( $file == $this_plugin ){ $org_settings_link = '' . __('Settings') . ''; $events_link = '' . __('Events') . ''; array_unshift( $links, $org_settings_link, $events_link ); // before other links } return $links; } add_filter( 'plugin_action_links', 'event_regis_filter_plugin_actions', 10, 2 ); function add_event_registration_menus() { add_menu_page('PayPal Events Registration', 'Events', 8, __FILE__, 'event_regis_main_mnu', EVNT_RGR_PLUGINFULLURL.'images/events_icon_16.png'); add_submenu_page(__FILE__, 'Configure Organization', 'Configure Organization', 8, __FILE__, 'event_regis_main_mnu'); add_submenu_page(__FILE__, 'Event Setup', 'Event Setup', 8, 'events', 'event_regis_manage_events'); add_submenu_page(__FILE__, 'Manage Event Categories', 'Event Categories', 8, 'event_categories', 'event_regis_categories_config_mnu'); add_submenu_page(__FILE__, 'Regform Setup', 'Regform Setup', 8, 'form', 'event_form_config'); //add_submenu_page(__FILE__, 'View Attendees', 'View Attendees', 8, 'attendees', 'event_registration_reports'); add_submenu_page(__FILE__, 'Attendees/Payments', 'Attendees/Payments', 8, 'admin_reports', 'event_admin_reports'); add_submenu_page(__FILE__, 'Help/Support', 'Help/Support', 8, 'support', 'event_regis_support'); } //ADMIN MENU add_action('admin_menu', 'add_event_registration_menus'); // Enable the ability for the event_funct to be loaded from pages add_filter('the_content','event_regis_insert'); add_filter('the_content','event_regis_attendees_insert'); add_filter('the_content','event_regis_pay_insert'); add_filter('the_content','event_paypal_txn_insert'); // Function to deal with loading the events into pages function event_regis_insert($content) { if (preg_match('{EVENTREGIS}',$content)) { $content = str_replace('{EVENTREGIS}',event_regis_run(),$content); } return $content; } function event_regis_attendees_insert($content) { if (preg_match('{EVENTATTENDEES}',$content)) { $content = str_replace('{EVENTATTENDEES}',event_attendee_list_run(),$content); } return $content; } function event_regis_pay_insert($content) { if (preg_match('{EVENTREGPAY}',$content)) { $content = str_replace('{EVENTREGPAY}',event_regis_pay(),$content); } return $content; } function event_paypal_txn_insert($content) { if (preg_match('{EVENTPAYPALTXN}',$content)) { $content = str_replace('{EVENTPAYPALTXN}',event_paypal_txn(),$content); } return $content; } /*********Shortcode support starts here************/ // [SINGLEEVENT single_event_id="your_event_identifier"] function show_single_event($atts) { extract(shortcode_atts(array('single_event_id' => 'No ID Supplied'), $atts)); $single_event_id = "{$single_event_id}"; register_attendees($single_event_id); } add_shortcode('SINGLEEVENT', 'show_single_event'); // [EVENT_REGIS_CATEGORY event_category_id="your_category_identifier"] function show_event_category($atts) { extract(shortcode_atts(array('event_category_id' => 'No Category ID Supplied'), $atts)); $event_category_id = "{$event_category_id}"; display_event_regis_categories($event_category_id); } add_shortcode('EVENT_REGIS_CATEGORY', 'show_event_category'); /*********Shortcode support ends here************/ //Date formatting function starts here function event_date_display($date){ if (empty($date)){ echo 'NO DATE SUPPLIED'; }else{ list($year, $month, $day) = split("-", $date); $event_date_display = date('M d, Y', mktime(0, 0, 0, $month, $day, $year)); } return $event_date_display; } //Run the program function event_regis_run(){ global $wpdb; $events_attendee_tbl = get_option('events_attendee_tbl'); $events_detail_tbl = get_option('events_detail_tbl'); $org_options = get_option('events_organization_settings'); $events_listing_type =$org_options['events_listing_type']; $event_page_id =$org_options['event_page_id']; if ($events_listing_type == ""){ echo "

Please setup Organization in the Admin Panel!

";} if ($events_listing_type == 'single'){ if ($_REQUEST['regevent_action'] == "post_attendee"){add_attedees_to_db();} else if ($_REQUEST['regevent_action'] == "pay"){event_regis_pay();} //Linked to from confirmation email else if ($_REQUEST['regevent_action'] == "register"){register_attendees();} else if ($_REQUEST['regevent_action'] == "paypal_txn"){event_regis_paypal_txn();} //Runs the paypal transaction else if ($regevent_action == "process"){} else {register_attendees();} } if ($events_listing_type == 'all'){ if ($_REQUEST['regevent_action'] == "post_attendee"){add_attedees_to_db();} else if ($_REQUEST['regevent_action'] == "pay"){event_regis_pay();} else if ($_REQUEST['regevent_action'] == "register"){register_attendees();} else if ($_REQUEST['regevent_action'] == "paypal_txn"){process_paypal_txn();} else if ($regevent_action == "process"){} else {display_all_events();} } } function event_form_build(&$question, $answer="") { $required = ''; if ($question->required == "Y") { $required = ' class="r"'; } switch ($question->question_type) { case "TEXT": echo "id\" name=\"TEXT-$question->id\" size=\"40\" title=\"$question->question\" value=\"$answer\" />\n"; break; case "TEXTAREA": echo "\n"; break; case "SINGLE": $values = explode(",", $question->response); $answers = explode(",", $answer); foreach ($values as $key => $value) { $checked = in_array($value, $answers)? " checked=\"checked\"": ""; echo "
\n"; } break; case "MULTIPLE": $values = explode(",", $question->response); $answers = explode(",", $answer); foreach ($values as $key => $value) { $checked = in_array($value, $answers)? " checked=\"checked\"": ""; echo "
\n"; } break; case "DROPDOWN": $values = explode(",", $question->response); $answers = $answer; echo ""; break; default: break; } } function add_attedees_to_db(){ global $wpdb; $org_options = get_option('events_organization_settings'); $Organization =$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 =$row['organization_zip']; $contact =$org_options['contact_email']; $registrar = $org_options['contact_email']; $paypal_id =$org_options['paypal_id']; $paypal_cur =$org_options['currency_format']; $return_url = $org_options['return_url']; $cancel_return = $org_options['cancel_return']; $notify_url = $org_options['notify_url']; $events_listing_type =$org_options['events_listing_type']; $default_mail=$org_options['default_mail']; $conf_message =$org_options['message']; $events_attendee_tbl = get_option('events_attendee_tbl'); $fname = $_POST['fname']; $lname = $_POST['lname']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $email = $_POST['email']; $hear = $_POST['hear']; $num_people = $_POST ['num_people']; $event_id=$_POST['event_id']; $payment = $_POST['payment']; $custom_1 =$_POST['custom_1']; $custom_2 =$_POST['custom_2']; $custom_3 =$_POST['custom_3']; $custom_4 =$_POST['custom_4']; $wpdb->query($wpdb->prepare("INSERT INTO ".$events_attendee_tbl." (lname ,fname ,address ,city ,state ,zip ,email ,phone ,hear, quantity, payment, event_id, custom_1, custom_2, custom_3, custom_4 ) VALUES ('$lname', '$fname', '$address', '$city', '$state', '$zip', '$email', '$phone', '$hear','$num_people', '$payment', '$event_id', '$custom_1', '$custom_2', '$custom_3', '$custom4')")); $attendee_id = $wpdb->get_var("SELECT LAST_INSERT_ID()"); // Insert Extra From Post Here $events_question_tbl = get_option('events_question_tbl'); $events_answer_tbl = get_option('events_answer_tbl'); $questions = $wpdb->get_results("SELECT * from `$events_question_tbl` where event_id = '$event_id'"); if ($questions) { foreach ($questions as $question) { switch ($question->question_type) { case "TEXT": case "TEXTAREA": case "SINGLE": $post_val = $_POST[$question->question_type . '-' . $question->id]; $wpdb->query($wpdb->prepare("INSERT into `$events_answer_tbl` (registration_id, question_id, answer) values ('$attendee_id', '$question->id', '$post_val')")); break; case "MULTIPLE": $values = explode(",", $question->response); $value_string = ''; foreach ($values as $key => $value) { $post_val = $_POST[$question->question_type . '-' . $question->id . '-' . $key]; if ($key > 0 && !empty($post_val)) $value_string .= ','; $value_string .= $post_val; } $wpdb->query($wpdb->prepare("INSERT into `$events_answer_tbl` (registration_id, question_id, answer) values ('$attendee_id', '$question->id', '$value_string')")); break; } } } $events_detail_tbl = get_option('events_detail_tbl'); $sql = "SELECT * FROM ". $events_detail_tbl ." WHERE id='".$event_id."'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc ($result)){ $event_name=$row['event_name']; $event_desc=$row['event_desc']; // BHC $display_desc=$row['display_desc']; $event_identifier=$row['event_identifier']; $reg_limit = $row['reg_limit']; $cost=$row['event_cost']; $start_time = $row['start_time']; $end_time = $row['end_time']; $active=$row['is_active']; $question1= $row['question1']; $question2= $row['question2']; $question3= $row['question3']; $question4= $row['question4']; $send_mail= $row['send_mail']; $conf_mail= $row['conf_mail']; $start_date = $row['start_date']; $end_date = $row['end_date']; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "From: " . $Organization . " <". $contact . ">\r\n"; $headers .= "Reply-To: " . $Organization . " <" . $contact . ">\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // Email Confirmation to Registrar $distro=$registrar; $message=("$fname $lname has signed up on-line for $event_name.\n\nEmail address is $email."); wp_mail($distro, $event_name, $message, $headers); //Email Confirmation to Attendee $payment_link = get_option('siteurl') . "/?page_id=" . $return_url . "&id=".$attendee_id; //Email Confirmation to Attendee $SearchValues = array( "[fname]", "[lname]", "[phone]", "[event]", "[description]", "[cost]", "[qst1]", "[qst2]", "[qst3]", "[qst4]", "[contact]", "[company]", "[co_add1]", "[co_add2]", "[co_city]", "[co_state]", "[co_zip]", "[payment_url]", "[start_date]", "[start_time]", "[end_date]", "[end_time]"); $ReplaceValues = array( $fname, $lname, $phone, $event_name, $event_desc, $cost, $question1, $question2, $question3, $question4, $contact, $Organization, $Organization_street1, $Organization_street2, $Organization_city, $Organization_state, $Organization_zip, $payment_link, $start_date, $start_time, $end_date, $end_time); $custom = str_replace($SearchValues, $ReplaceValues, $conf_mail); $default_replaced = str_replace($SearchValues, $ReplaceValues, $conf_message); $distro="$email"; $message_top = ""; $message_bottom = ""; $email_body = $message_top.$custom.$message_bottom; //wp_mail($payer_email,$subject,$body,$headers); if ($default_mail =='Y'){ if($send_mail == 'Y'){ wp_mail($distro, $event_name, html_entity_decode($email_body), $headers);}} if ($default_mail =='Y'){ if($send_mail == 'N'){ wp_mail($distro, $event_name, $default_replaced, $headers);}} //Get registrars id from the data table and assign to a session variable for PayPal. $query = "SELECT * FROM $events_attendee_tbl WHERE id = '".$attendee_id."'"; $result = mysql_query($query) or die('Error : ' . mysql_error()); while ($row = mysql_fetch_assoc ($result)) { //$attendee_id = $row['id']; $lname = $row['lname']; $fname = $row['fname']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $email = $row['email']; $phone = $row['phone']; $date = $row['date']; $payment_status = $row['payment_status']; $txn_type = $row['txn_type']; $amount_pd = $row['amount_pd']; $payment_date = $row['payment_date']; $event_id = $row['event_id']; $custom1 = $row['custom_1']; $custom2 = $row['custom_2']; $custom3 = $row['custom_3']; $custom4 = $row['custom_4']; } //update_option("attendee_id", $id); //Send screen confirmation & forward to paypal if selected. if ($cost== '' || $cost== ' ' || $cost== '0.00'){ $event_message = '

This is a free event. Details have been sent to your email.

'; }else{ $event_message = '

Payment must be made to complete registration. Please click the button below to pay for your registration.

'; } ?>

Your Registration data has been added to our records.

"; while ($row = mysql_fetch_assoc ($result)){ $id = $row['id']; $lname = $row['lname']; $fname = $row['fname']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $email = $row['email']; $phone = $row['phone']; $date = $row['date']; $payment_status = $row['payment_status']; $txn_type = $row['txn_type']; $amount_pd = $row['amount_pd']; $payment_date = $row['payment_date']; $event_id = $row['event_id']; $custom1 = $row['custom_1']; $custom2 = $row['custom_2']; $custom3 = $row['custom_3']; $custom4 = $row['custom_4']; echo "".$lname.", ".$fname."".$email."".$phone.""; echo ""; echo "
"; echo ""; echo ""; echo "
"; echo ""; } echo ""; } function attendee_display_edit(){ edit_attendee_record(); event_list_attendees(); } //Export data to Excel file switch ($_REQUEST['export']) { case "report"; global $wpdb; $id= $_REQUEST['id']; $events_attendee_tbl = $_REQUEST['atnd']; $today = date("Y-m-d_Hi",time()); $events_answer_tbl = get_option('events_answer_tbl'); $events_question_tbl = get_option('events_question_tbl'); $events_detail_tbl = get_option('events_detail_tbl'); $events_attendee_tbl = get_option('events_attendee_tbl'); $sql = "SELECT * FROM " . $events_detail_tbl . " WHERE id='$id'"; $result = mysql_query($sql); list($event_id, $event_name, $event_description, $event_identifier, $event_cost, $is_active) = mysql_fetch_array($result, MYSQL_NUM); switch ($_REQUEST['action']) { case "excel"; $st = ""; $et = "\t"; $s = $et . $st; $basic_header = array('Reg ID', 'Last Name', 'First Name', 'Email', 'Address', 'City', 'State', 'Zip', 'Phone', 'Payment Method', 'Reg Date'); $question_sequence = array(); $questions = $wpdb->get_results("select question, sequence from ".$events_question_tbl." where event_id = '$event_id' order by sequence"); foreach ($questions as $question) { array_push($basic_header, $question->question); array_push($question_sequence, $question->sequence); } $participants = $wpdb->get_results("SELECT * from $events_attendee_tbl where event_id = '$event_id'"); $filename = $event_name."-Attendees_". $today . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); header("Pragma: no-cache"); header("Expires: 0"); //echo header echo implode($s, $basic_header) . $et . "\r\n"; //echo data if ($participants) { foreach ($participants as $participant) { echo $participant->id . $s . $participant->lname . $s . $participant->fname . $s . $participant->email . $s . $participant->address . $s . $participant->city . $s . $participant->state . $s . $participant->zip . $s . $participant->phone . $s . $participant->payment . $s . $participant->date; $answers = $wpdb->get_results("select a.answer from ".$events_answer_tbl." a join ".$events_question_tbl." q on q.id = a.question_id where registration_id = '$participant->id' order by q.sequence"); foreach($answers as $answer) { echo $s . $answer->answer; } echo $et . "\r\n"; } } else { echo "No participant data has been collected."; } exit; break; case "payment"; $st = ""; $et = "\t"; $s = $et . $st; $basic_header = array('Reg ID', 'Last Name', 'First Name', 'Email', 'Address', 'City', 'State', 'Zip', 'Phone', 'Payment Method', 'Reg Date', 'Pay Status', 'Type of Payment', 'Transaction ID', 'Payment', '# Attendees', 'Date Paid', 'Answers' ); $question_sequence = array(); $participants = $wpdb->get_results("SELECT * from $events_attendee_tbl where event_id = '$event_id'"); $filename = $event_name."-Payments_". $today . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); header("Pragma: no-cache"); header("Expires: 0"); //echo header echo implode($s, $basic_header) . $et . "\r\n"; //echo data if ($participants) { foreach ($participants as $participant) { echo $participant->id . $s . $participant->lname . $s . $participant->fname . $s . $participant->email . $s . $participant->address . $s . $participant->city . $s . $participant->state . $s . $participant->zip . $s . $participant->phone . $s . $participant->payment . $s . $participant->date . $s . $participant->payment_status . $s . $participant->txn_type . $s . $participant->txn_id . $s . $participant->amount_pd . $s . $participant->quantity . $s . $participant->payment_date ; $answers = $wpdb->get_results("select a.answer from ".$events_answer_tbl." a join ".$events_question_tbl." q on q.id = a.question_id where registration_id = '$participant->id' order by q.sequence"); foreach($answers as $answer) { echo $s . $answer->answer; } echo $et . "\r\n"; } } else { echo "No participant data has been collected."; } exit; break; default: echo "This Is Not A Valid Selection!"; break; } default: break; } ?>