Buy a Support License | Donate | Support
Version: 2.1.27
Author: Seth Shoultes
Author URI: http://www.shoultes.net
Contributors:
Ben Dunkle http://field2.com - Icon Design - Thanks Ben!!
Chris Reynolds (jazzs3quence) http://arcanepalette.com - minor bugfixes
*/
/* Copyright 2010 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
*/
error_reporting(E_ALL ^ E_NOTICE);
//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', 'espresso_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");
require("includes/admin_upgrade.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', 'Event Manager', 'administrator', __FILE__, 'event_regis_main_mnu', EVNT_RGR_PLUGINFULLURL.'images/events_icon_16.png');
add_submenu_page(__FILE__, 'Configure Organization', 'Configure Organization', 'administrator', __FILE__, 'event_regis_main_mnu');
add_submenu_page(__FILE__, 'Event Setup', 'Event Setup', 'administrator', 'events', 'event_regis_manage_events');
add_submenu_page(__FILE__, 'Manage Event Categories', 'Event Categories', 'administrator', 'event_categories', 'event_regis_categories_config_mnu');
add_submenu_page(__FILE__, 'Regform Setup', 'Regform Setup', 'administrator', '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', 'administrator', 'admin_reports', 'event_admin_reports');
add_submenu_page(__FILE__, 'Help/Support', 'Help/Support', 'administrator', 'support', 'event_regis_support');
add_submenu_page(__FILE__, 'Upgrade to Pro', 'Upgrade to Pro', 'administrator', 'upgrade', 'event_regis_upgrade');
}
//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))
{
ob_start();
event_regis_run();
$buffer = ob_get_contents();
ob_end_clean();
$content = str_replace('{EVENTREGIS}',$buffer,$content);
}
return $content;
}
function event_regis_attendees_insert($content)
{
if (preg_match('{EVENTATTENDEES}',$content))
{
ob_start();
event_attendee_list_run();
$buffer = ob_get_contents();
ob_end_clean();
$content = str_replace('{EVENTATTENDEES}',$buffer,$content);
}
return $content;
}
function event_regis_pay_insert($content)
{
if (preg_match('{EVENTREGPAY}',$content))
{
ob_start();
event_regis_pay();
$buffer = ob_get_contents();
ob_end_clean();
$content = str_replace('{EVENTREGPAY}',$buffer,$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}";
ob_start();
register_attendees($single_event_id);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
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}";
ob_start();
display_event_regis_categories($event_category_id);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
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) = explode("-", $date); // fixed by jazzs3quence 9/10/2010
$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_detail_tbl = get_option('events_detail_tbl');
$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'];
$country = $_POST['country'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$hear = $_POST['hear'];
$num_people = $_POST ['num_people'];
$event_id=$_POST['event_id'];
$payment = $_POST['payment'];
//Query Database for Active event and get variable
$sql = "SELECT * FROM ". $events_detail_tbl . " WHERE id ='$event_id'";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc ($result)){
//$event_id = $row['id'];
$event_name = $row['event_name'];
$event_desc = $row['event_desc'];
$event_description = $row['event_desc'];
$event_identifier = $row['event_identifier'];
$event_cost = $row['event_cost'];
$send_mail = $row['send_mail'];
$active = $row['is_active'];
$conf_mail = $row['conf_mail'];
$use_coupon_code = $row['use_coupon_code'];
$coupon_code = $row['coupon_code'];
$coupon_code_price = $row['coupon_code_price'];
$use_percentage= $row['use_percentage'];
//$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'];
$send_mail= $row['send_mail'];
//$conf_mail= $row['conf_mail'];
$start_date = $row['start_date'];
$end_date = $row['end_date'];
}
//Get pricing data
$event_cost = $event_cost * $num_people;
if ($use_coupon_code == "Y"){
if ($_REQUEST['coupon_code'] != ''){
if ($coupon_code == $_POST['coupon_code']){
$valid_discount = true;
$discount_type_price = $use_percentage == 'Y' ? $coupon_code_price.'%' : $org_options['currency_symbol'].$coupon_code_price;
_e('
You are using discount code: '.$coupon_code.' ('.$discount_type_price.' discount)
','event_regis'); if($use_percentage == 'Y'){ $pdisc = $coupon_code_price / 100; $event_cost = $event_cost - ($event_cost * $pdisc); }else{ $event_cost = $event_cost - $coupon_code_price; } if($event_cost == '0.00'){ $event_cost = __('0.00','event_regis'); $payment_status = __('Completed','event_regis'); } /*$sql=array('coupon_code'=>$_REQUEST['coupon_code'], 'amount_pd'=>$event_cost, 'payment_status'=>$payment_status); $sql_data = array('%s','%s','%s'); $update_id = array('id'=> $attendee_id); $wpdb->update($events_attendee_tbl, $sql, $update_id, $sql_data, array( '%d' ) );*/ //print_r( $sql ); }else{ _e('Sorry, that coupon code is invalid or expired.
','event_regis'); } } }else { if($event_cost == '0.00'){ //$event_cost_disp = __('0.00','event_regis'); $payment_status = __('Completed','event_regis'); } /*$sql=array('amount_pd'=>$event_cost, 'payment_status'=>$payment_status); $sql_data = array('%s','%s'); $update_id = array('id'=> $attendee_id); $wpdb->update($events_attendee_tbl, $sql, $update_id, $sql_data, array( '%d' ) );*/ } $att_sql ="INSERT INTO ".$events_attendee_tbl." (lname ,fname ,address ,city ,state ,zip, country, email ,phone ,hear, quantity, payment, amount_pd, payment_status, coupon_code, event_id ) VALUES ('$lname', '$fname', '$address', '$city', '$state', '$zip', '$country', '$email', '$phone', '$hear','$num_people', '$payment', '$event_cost', '$payment_status', '" . $_REQUEST['coupon_code'] . "', '$event_id')"; //echo $att_sql; $wpdb->query($wpdb->prepare($att_sql)); $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']; $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]", "[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, $org_options['currency_symbol'] . $event_cost, $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 = 'Event Registration Powered by Event Espresso
'; $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( wpautop($email_body)), $headers);}} if ($default_mail =='Y'){ if($send_mail == 'N'){ wp_mail($distro, $event_name, html_entity_decode( wpautop($default_replaced.'Event Registration Powered by Event Espresso
')), $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']; } //update_option("attendee_id", $id); //Send screen confirmation & forward to paypal if selected. if ($amount_pd== '' || $amount_pd== ' ' || $amount_pd== '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']; echo "There are two ways to upgrade. Purchase a premium support license directly from Event Espresso, from the WP Plugins App Store or using the button below.
Advanced Events Registration must be configured. Go to the Organization Settings page to configure the plugin "Page Settings."
Advanced Events Registration must be configured. Go to the Organization Settings page to configure the plugin "Page Settings."