/**
  * Gets the default form structure for creating a new form
  * @return array
  */
 public static function get_form_template()
 {
     if (empty(self::$form_template)) {
         self::$form_template = apply_filters('em_booking_form_get_form_template', array('name' => array('label' => __emp('Name', 'dbem'), 'type' => 'name', 'fieldid' => 'user_name', 'required' => 1), 'user_email' => array('label' => __emp('Email', 'dbem'), 'type' => 'user_email', 'fieldid' => 'user_email', 'required' => 1), 'dbem_address' => array('label' => __emp('Address', 'dbem'), 'type' => 'dbem_address', 'fieldid' => 'dbem_address', 'required' => 1), 'dbem_city' => array('label' => __emp('City/Town', 'dbem'), 'type' => 'dbem_city', 'fieldid' => 'dbem_city', 'required' => 1), 'dbem_state' => array('label' => __emp('State/County', 'dbem'), 'type' => 'dbem_state', 'fieldid' => 'dbem_state', 'required' => 1), 'dbem_zip' => array('label' => __('Zip/Post Code', 'em-pro'), 'type' => 'dbem_zip', 'fieldid' => 'dbem_zip', 'required' => 1), 'dbem_country' => array('label' => __emp('Country', 'dbem'), 'type' => 'dbem_country', 'fieldid' => 'dbem_country', 'required' => 1), 'dbem_phone' => array('label' => __emp('Phone', 'dbem'), 'type' => 'dbem_phone', 'fieldid' => 'dbem_phone'), 'dbem_fax' => array('label' => __('Fax', 'em-pro'), 'type' => 'dbem_fax', 'fieldid' => 'dbem_fax'), 'booking_comment' => array('label' => __emp('Comment', 'dbem'), 'type' => 'textarea', 'fieldid' => 'booking_comment')));
     }
     return self::$form_template;
 }
예제 #2
0
 /**
  * Gets data from POST (default), supplied array, or from the database if an ID is supplied
  * @param $coupon_data
  * @param $search_by can be set to post_id or a number for a blog id if in ms mode with global tables, default is coupon_id
  * @return null
  */
 function __construct($id = false, $search_by = 'id')
 {
     global $wpdb;
     //Initialize
     $this->required_fields = array("coupon_name" => __emp('Name', 'dbem'), "coupon_discount" => __('Discount', 'em-pro'), "coupon_code" => __('Code', 'em-pro'));
     //Get the array/coupon_id
     if (is_numeric($id) && $search_by == 'id') {
         //search by coupon_id, get post_id and blog_id (if in ms mode) and load the post
         $coupon = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . EM_COUPONS_TABLE . " WHERE coupon_id=%d", $id), ARRAY_A);
     } elseif ($search_by == 'code') {
         //search by coupon_id, get post_id and blog_id (if in ms mode) and load the post
         $coupon = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . EM_COUPONS_TABLE . " WHERE coupon_code='%s'", $id), ARRAY_A);
     } elseif (is_array($id)) {
         $coupon = $id;
     }
     if (!empty($coupon) && is_array($coupon) && !empty($coupon['coupon_code'])) {
         foreach ($coupon as $key => $value) {
             //merge the post data into coupon object
             $this->{$key} = $value;
         }
     }
     $this->id = $this->coupon_id;
     $this->owner = $this->coupon_owner;
     if (empty($this->coupon_tax)) {
         //special tax consideration for EM <5.4
         if (get_option('dbem_legacy_bookings_tax_auto_add', 'x') !== 'x') {
             $this->coupon_tax = get_option('dbem_legacy_bookings_tax_auto_add') ? 'post' : 'pre';
         } else {
             $this->coupon_tax = get_option('dbem_bookings_tax_auto_add') ? 'post' : 'pre';
         }
     }
     do_action('em_coupon', $this, $id);
 }
예제 #3
0
 /**
  * Validates a coupon to make sure the submitted fields include required ones
  * @return boolean
  */
 function validate()
 {
     $validate = true;
     foreach ($this->required_fields as $field => $msg) {
         if (empty($this->{$field})) {
             $validate = false;
             $this->add_error(sprintf(__emp("%s is required.", "dbem"), $msg));
         }
     }
     return apply_filters('em_coupon_validate', $validate, $this);
 }
예제 #4
0
?>
'/>
						 	<input type='hidden' name='event_id' value='<?php 
echo $EM_Event->event_id;
?>
'/>
						 	<input type='hidden' name='_wpnonce' value='<?php 
echo wp_create_nonce('booking_set_status_' . $EM_Multiple_Booking->booking_id);
?>
'/>
							<p><em><?php 
echo wp_kses_data(__('<strong>Warning:</strong> Status changes made here will be applied to all the bookings below.', 'em-pro'));
?>
</em>
							<br /><em><?php 
echo wp_kses_data(__emp('<strong>Notes:</strong> Ticket availability not taken into account when approving new bookings (i.e. you can overbook).', 'dbem'));
?>
</em>
							</p>
						</form>
					</div>
					<form action="" method="post" class="em-booking-form">
						<?php 
emp_locate_template('multiple-bookings/admin-cart-table.php', true, array('EM_Multiple_Booking' => $EM_Multiple_Booking));
?>
						<table class="em-form-fields" cellspacing="0" cellpadding="0">
							<div class="em-booking-single-edit">
								<p><em><?php 
_e('You are editing the information supplied no the checkout form. To edit information about a specific booking, including the data entered in that booking form, click the edit link on your bookings above.', 'em-pro');
?>
</em></p>
<?php

/*
* This displays the content of the #_BOOKINGATTENDEES placeholder in Multiple Bookings mode.
* You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager-pro/placeholders/ and modifying it however you need.
* For more information, see http://wp-events-plugin.com/documentation/using-template-files/
*/
foreach ($EM_Multiple_Booking->get_bookings() as $EM_Booking) {
    /* @var $EM_Booking EM_Booking */
    echo "\r\n" . __emp('Event', 'dbem') . ' - ' . $EM_Booking->get_event()->event_name . "\r\n" . '==============================';
    emp_locate_template('placeholders/bookingattendees.php', true, array('EM_Booking' => $EM_Booking));
}
/**
 * Shortcut for the _e function
 * @param string $text
 * @param string $domain
 */
function _e_emp($text, $domain = 'dbem')
{
    echo __emp($text, $domain);
}
<?php

/*
* This displays the content of the #_BOOKINGATTENDEES placeholder.
* You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager-pro/placeholders/ and modifying it however you need.
* For more information, see http://wp-events-plugin.com/documentation/using-template-files/
*/
$EM_Tickets_Bookings = $EM_Booking->get_tickets_bookings();
$attendee_datas = EM_Attendees_Form::get_booking_attendees($EM_Booking);
foreach ($EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking) {
    //Display ticket info
    if (!empty($attendee_datas[$EM_Ticket_Booking->ticket_id])) {
        echo "\r\n" . __emp('Ticket', 'dbem') . ' - ' . $EM_Ticket_Booking->get_ticket()->ticket_name . "\r\n" . '-----------------------------';
        //display a row for each space booked on this ticket
        foreach ($attendee_datas[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data) {
            echo "\r\n" . $attendee_title . "\r\n" . '------------';
            foreach ($attendee_data as $field_label => $field_value) {
                echo "\r\n" . $field_label . ': ';
                echo $field_value;
                echo "\r\n";
            }
        }
    }
}
 /**
  * Intercepts a CSV export request before the core version hooks in and using similar code generates a breakdown of bookings with all attendees included at the end.
  * Hooking into the original version of this will cause more looping, which is why we're flat out overriding this here.
  */
 public static function intercept_csv_export()
 {
     if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'export_bookings_csv' && !empty($_REQUEST['show_attendees']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'export_bookings_csv')) {
         //sort out cols
         if (!empty($_REQUEST['cols']) && is_array($_REQUEST['cols'])) {
             $cols = array();
             foreach ($_REQUEST['cols'] as $col => $active) {
                 if ($active) {
                     $cols[] = $col;
                 }
             }
             $_REQUEST['cols'] = $cols;
         }
         $_REQUEST['limit'] = 0;
         //generate bookings export according to search request
         $EM_Bookings_Table = new EM_Bookings_Table(true);
         header("Content-Type: application/octet-stream; charset=utf-8");
         header("Content-Disposition: Attachment; filename=" . sanitize_title(get_bloginfo()) . "-bookings-export.csv");
         do_action('em_csv_header_output');
         echo "";
         // UTF-8 for MS Excel (a little hacky... but does the job)
         if (!defined('EM_CSV_DISABLE_HEADERS') || !EM_CSV_DISABLE_HEADERS) {
             if (!empty($_REQUEST['event_id'])) {
                 $EM_Event = em_get_event($_REQUEST['event_id']);
                 _e_emp('Event', 'dbem') . ' : ' . $EM_Event->event_name . "\n";
                 if ($EM_Event->location_id > 0) {
                     _e_emp('Where', 'dbem') . ' - ' . $EM_Event->get_location()->location_name . "\n";
                 }
                 _e_emp('When', 'dbem') . ' : ' . $EM_Event->output('#_EVENTDATES - #_EVENTTIMES') . "\n";
             }
             echo sprintf(__emp('Exported bookings on %s', 'dbem'), date_i18n('D d M Y h:i', current_time('timestamp'))) . "\n";
         }
         $headers = $EM_Bookings_Table->get_headers(true);
         if (!empty($_REQUEST['event_id'])) {
             foreach (self::get_form($_REQUEST['event_id'])->form_fields as $field) {
                 if ($field['type'] != 'html') {
                     $headers[] = $field['label'];
                 }
             }
         }
         echo '"' . implode('","', $headers) . '"' . "\n";
         //Rows
         $EM_Bookings_Table->limit = 150;
         //if you're having server memory issues, try messing with this number
         $EM_Bookings = $EM_Bookings_Table->get_bookings();
         $handle = fopen("php://output", "w");
         while (!empty($EM_Bookings->bookings)) {
             foreach ($EM_Bookings->bookings as $EM_Booking) {
                 /* @var $EM_Booking EM_Booking */
                 /* @var $EM_Ticket_Booking EM_Ticket_Booking */
                 $attendees_data = self::get_booking_attendees($EM_Booking);
                 foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
                     $orig_row = $EM_Bookings_Table->get_row_csv($EM_Ticket_Booking);
                     if (!empty($attendees_data[$EM_Ticket_Booking->ticket_id])) {
                         foreach ($attendees_data[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data) {
                             $row = $orig_row;
                             foreach ($attendee_data as $field_value) {
                                 $row[] = $field_value;
                             }
                             fputcsv($handle, $row);
                         }
                     }
                 }
             }
             //reiterate loop
             $EM_Bookings_Table->offset += $EM_Bookings_Table->limit;
             $EM_Bookings = $EM_Bookings_Table->get_bookings();
         }
         fclose($handle);
         exit;
     }
 }
예제 #9
0
function emp_add_options()
{
    global $wpdb;
    add_option('em_pro_data', array());
    add_option('dbem_disable_css', false);
    //TODO - remove this or create dependency in admin settings
    //Form Stuff
    $booking_form_data = array('name' => __('Default', 'em-pro'), 'form' => array('name' => array('label' => __emp('Name', 'dbem'), 'type' => 'name', 'fieldid' => 'user_name', 'required' => 1), 'user_email' => array('label' => __emp('Email', 'dbem'), 'type' => 'user_email', 'fieldid' => 'user_email', 'required' => 1), 'dbem_address' => array('label' => __emp('Address', 'dbem'), 'type' => 'dbem_address', 'fieldid' => 'dbem_address', 'required' => 1), 'dbem_city' => array('label' => __emp('City/Town', 'dbem'), 'type' => 'dbem_city', 'fieldid' => 'dbem_city', 'required' => 1), 'dbem_state' => array('label' => __emp('State/County', 'dbem'), 'type' => 'dbem_state', 'fieldid' => 'dbem_state', 'required' => 1), 'dbem_zip' => array('label' => __('Zip/Post Code', 'em-pro'), 'type' => 'dbem_zip', 'fieldid' => 'dbem_zip', 'required' => 1), 'dbem_country' => array('label' => __emp('Country', 'dbem'), 'type' => 'dbem_country', 'fieldid' => 'dbem_country', 'required' => 1), 'dbem_phone' => array('label' => __emp('Phone', 'dbem'), 'type' => 'dbem_phone', 'fieldid' => 'dbem_phone'), 'dbem_fax' => array('label' => __('Fax', 'em-pro'), 'type' => 'dbem_fax', 'fieldid' => 'dbem_fax'), 'booking_comment' => array('label' => __emp('Comment', 'dbem'), 'type' => 'textarea', 'fieldid' => 'booking_comment')));
    add_option('em_booking_form_error_required', __('Please fill in the field: %s', 'em-pro'));
    $new_fields = array('dbem_address' => array('label' => __emp('Address', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_address', 'required' => 1), 'dbem_address_2' => array('label' => __emp('Address Line 2', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_address_2'), 'dbem_city' => array('label' => __emp('City/Town', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_city', 'required' => 1), 'dbem_state' => array('label' => __emp('State/County', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_state', 'required' => 1), 'dbem_zip' => array('label' => __('Zip/Post Code', 'em-pro'), 'type' => 'text', 'fieldid' => 'dbem_zip', 'required' => 1), 'dbem_country' => array('label' => __emp('Country', 'dbem'), 'type' => 'country', 'fieldid' => 'dbem_country', 'required' => 1), 'dbem_phone' => array('label' => __emp('Phone', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_phone'), 'dbem_fax' => array('label' => __('Fax', 'em-pro'), 'type' => 'text', 'fieldid' => 'dbem_fax'), 'dbem_company' => array('label' => __('Company', 'em-pro'), 'type' => 'text', 'fieldid' => 'dbem_company'));
    add_option('em_user_fields', $new_fields);
    $customer_fields = array('address' => 'dbem_address', 'address_2' => 'dbem_address_2', 'city' => 'dbem_city', 'state' => 'dbem_state', 'zip' => 'dbem_zip', 'country' => 'dbem_country', 'phone' => 'dbem_phone', 'fax' => 'dbem_fax', 'company' => 'dbem_company');
    add_option('emp_gateway_customer_fields', $customer_fields);
    add_option('em_attendee_fields_enabled', defined('EM_ATTENDEES') && EM_ATTENDEES);
    //Gateway Stuff
    add_option('dbem_emp_booking_form_reg_input', 1);
    add_option('dbem_emp_booking_form_reg_show', 1);
    add_option('dbem_emp_booking_form_reg_show_email', 0);
    add_option('dbem_emp_booking_form_reg_show_name', !get_option('em_pro_version'));
    add_option('dbem_gateway_use_buttons', 0);
    add_option('dbem_gateway_label', __('Pay With', 'em-pro'));
    //paypal
    add_option('em_paypal_option_name', __('PayPal', 'em-pro'));
    add_option('em_paypal_form', '<img src="' . plugins_url('events-manager-pro/includes/images/paypal/paypal_info.png', 'events-manager') . '" width="228" height="61" />');
    add_option('em_paypal_booking_feedback', __('Please wait whilst you are redirected to PayPal to proceed with payment.', 'em-pro'));
    add_option('em_paypal_booking_feedback_free', __emp('Booking successful.', 'dbem'));
    add_option('em_paypal_button', 'http://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif');
    add_option('em_paypal_booking_feedback_thanks', __('Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you along with a separate email containing account details to access your booking information on this site. You may log into your account at www.paypal.com to view details of this transaction.', 'em-pro'));
    add_option('em_paypal_inc_tax', get_option('em_pro_version') == false);
    //offline
    add_option('em_offline_option_name', __('Pay Offline', 'em-pro'));
    add_option('em_offline_booking_feedback', __emp('Booking successful.', 'dbem'));
    add_option('em_offline_button', __('Pay Offline', 'em-pro'));
    //authorize.net
    add_option('em_authorize_aim_option_name', __('Credit Card', 'em-pro'));
    add_option('em_authorize_aim_booking_feedback', __emp('Booking successful.', 'dbem'));
    add_option('em_authorize_aim_booking_feedback_free', __('Booking successful. You have not been charged for this booking.', 'em-pro'));
    //email reminders
    add_option('dbem_cron_emails', 0);
    add_option('dbem_cron_emails_limit', get_option('emp_cron_emails_limit', 100));
    add_option('dbem_emp_emails_reminder_subject', __('Reminder', 'em-pro') . ' - #_EVENTNAME');
    $email_footer = '<br /><br />-------------------------------<br />Powered by Events Manager - http://wp-events-plugin.com';
    $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />This is a reminder about your #_BOOKINGSPACES space/spaces reserved for #_EVENTNAME.<br />When : #_EVENTDATES @ #_EVENTTIMES<br />Where : #_LOCATIONNAME - #_LOCATIONFULLLINE<br />We look forward to seeing you there!<br />Yours faithfully,<br />#_CONTACTNAME", 'em-pro') . $email_footer;
    add_option('dbem_emp_emails_reminder_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    add_option('dbem_emp_emails_reminder_time', '12:00 AM');
    add_option('dbem_emp_emails_reminder_days', 1);
    add_option('dbem_emp_emails_reminder_ical', 1);
    //custom emails
    add_option('dbem_custom_emails', 0);
    add_option('dbem_custom_emails_events', 1);
    add_option('dbem_custom_emails_events_admins', 1);
    add_option('dbem_custom_emails_gateways', 1);
    add_option('dbem_custom_emails_gateways_admins', 1);
    //multiple bookings
    add_option('dbem_multiple_bookings_feedback_added', __('Your booking was added to your shopping cart.', 'em-pro'));
    add_option('dbem_multiple_bookings_feedback_already_added', __('You have already booked a spot at this eventin your cart, please modify or delete your current booking.', 'em-pro'));
    add_option('dbem_multiple_bookings_feedback_no_bookings', __('You have not booked any events yet. Your cart is empty.', 'em-pro'));
    add_option('dbem_multiple_bookings_feedback_loading_cart', __('Loading Cart Contents...', 'em-pro'));
    add_option('dbem_multiple_bookings_feedback_empty_cart', __('Are you sure you want to empty your cart?', 'em-pro'));
    add_option('dbem_multiple_bookings_submit_button', __('Place Order', 'em_pro'));
    //multiple bookings - emails
    add_option('dbem_multiple_bookings_contact_email_subject', __('New Booking', 'em-pro'));
    $respondent_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) has made a booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer;
    add_option('dbem_multiple_bookings_contact_email_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    add_option('dbem_multiple_bookings_contact_email_cancelled_subject', __('Booking Cancelled', 'em-pro'));
    $respondent_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) has cancelled a booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer;
    add_option('dbem_multiple_bookings_contact_email_cancelled_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    add_option('dbem_multiple_bookings_email_confirmed_subject', __('Booking Confirmed', 'em-pro'));
    $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your booking has been confirmed. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY <br />We look forward to seeing you there!", 'em-pro') . $email_footer;
    add_option('dbem_multiple_bookings_email_confirmed_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    add_option('dbem_multiple_bookings_email_pending_subject', __('Booking Pending', 'em-pro'));
    $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your booking is currently pending approval by our administrators. Once approved you will receive another confirmation email. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer;
    add_option('dbem_multiple_bookings_email_pending_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    add_option('dbem_multiple_bookings_email_rejected_subject', __('Booking Rejected', 'em-pro'));
    $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your requested booking has been rejected. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer;
    add_option('dbem_multiple_bookings_email_rejected_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    add_option('dbem_multiple_bookings_email_cancelled_subject', __('Booking Cancelled', 'em-pro'));
    $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your requested booking has been cancelled. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer;
    add_option('dbem_multiple_bookings_email_cancelled_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable));
    //Version updates
    if (get_option('em_pro_version')) {
        //upgrade, so do any specific version updates
        if (get_option('em_pro_version') < 2.16) {
            //add new customer information fields
            $user_fields = get_option('em_user_fields', array());
            update_option('em_user_fields', array_merge($new_fields, $user_fields));
        }
        if (get_option('em_pro_version') < 2.061) {
            //new booking form data structure
            global $wpdb;
            //backward compatability, check first field to see if indexes start with 'booking_form_...' and change this.
            $form_fields = get_option('em_booking_form_fields', $booking_form_data['form']);
            if (is_array($form_fields)) {
                $booking_form_fields = array();
                foreach ($form_fields as $form_field_id => $form_field_data) {
                    foreach ($form_field_data as $field_key => $value) {
                        $field_key = str_replace('booking_form_', '', $field_key);
                        $booking_form_fields[$form_field_id][$field_key] = $value;
                    }
                }
                //move booking form to meta table and update wp option with booking form id too
                $booking_form = serialize(array('name' => __('Default', 'em-pro'), 'form' => $booking_form_fields));
                if ($wpdb->insert(EM_META_TABLE, array('meta_key' => 'booking-form', 'meta_value' => $booking_form, 'object_id' => 0))) {
                    update_option('em_booking_form_fields', $wpdb->insert_id);
                }
            }
        }
        if (get_option('em_pro_version') < 1.6) {
            //make buttons the default option
            update_option('dbem_gateway_use_buttons', 1);
            if (get_option('em_offline_button_text') && !get_option('em_offline_button')) {
                update_option('em_offline_button', get_option('em_offline_button_text'));
                //merge offline quick pay button option into one
            }
            if (get_option('em_paypal_button_text') && !get_option('em_paypal_button')) {
                update_option('em_paypal_button', get_option('em_paypal_button_text'));
                //merge offline quick pay button option into one
            }
        }
        if (get_option('em_pro_version') < 2.243) {
            //fix badly stored user dates and times
            $EM_User_Form = EM_User_Fields::get_form();
            foreach ($EM_User_Form->form_fields as $field_id => $field) {
                if (in_array($field['type'], array('date', 'time'))) {
                    //search the user meta table and modify all occorunces of this value if the format isn't correct
                    $meta_results = $wpdb->get_results("SELECT umeta_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key='" . $field_id . "'", ARRAY_A);
                    foreach ($meta_results as $meta_result) {
                        if (is_serialized($meta_result['meta_value'])) {
                            $meta_value = unserialize($meta_result['meta_value']);
                            if (is_array($meta_value) && !empty($meta_value['start'])) {
                                $new_value = $meta_value['start'];
                                if (!empty($meta_value['end'])) {
                                    $new_value .= ',' . $meta_value['end'];
                                }
                                //update this user meta with the new value
                                $wpdb->query("UPDATE {$wpdb->usermeta} SET meta_value='{$new_value}' WHERE umeta_id='{$meta_result['umeta_id']}'");
                            }
                        }
                    }
                }
            }
        }
        if (get_option('em_pro_version') < 2.36) {
            //disable custom emails for upgrades, prevent unecessary features
            add_option('dbem_custom_emails', 0);
        }
        if (get_option('dbem_muliple_bookings_form')) {
            //fix badly stored user dates and times
            update_option('dbem_multiple_bookings_form', get_option('dbem_muliple_bookings_form'));
            delete_option('dbem_muliple_bookings_form');
        }
    } else {
        //Booking form stuff only run on install
        $insert_result = $wpdb->insert(EM_META_TABLE, array('meta_value' => serialize($booking_form_data), 'meta_key' => 'booking-form', 'object_id' => 0));
        add_option('em_booking_form_fields', $wpdb->insert_id);
    }
}
 public static function get_gateway_default_emails($EM_Gateway = false)
 {
     global $EM_Gateways;
     $emails = array();
     $gateways = is_object($EM_Gateway) ? array($EM_Gateway->gateway => $EM_Gateway->title) : EM_Gateways::active_gateways();
     foreach ($gateways as $gateway => $gateway_name) {
         $emails[$gateway] = array('title' => sprintf(__('%s Gateway Emails', 'em-pro'), $gateway_name), 'subgroups' => array($gateway . '-admin' => array('title' => __('Event Owner Emails', 'em-pro'), 'text' => __('These emails get sent to the event owners when a person has made a booking using this specific gateway.', 'em-pro'), 'emails' => array(0 => array('title' => __emp('Pending booking email', 'dbem')), 1 => array('title' => __emp('Confirmed booking email', 'dbem')), 3 => array('title' => __emp('Booking cancelled', 'dbem')))), $gateway . '-user' => array('title' => __('Attendee Emails', 'em-pro'), 'text' => __('These emails will be sent to the person who booked a place at your event and selected this specific gateway.', 'em-pro'), 'emails' => array(0 => array('title' => __emp('Pending booking email', 'dbem')), 1 => array('title' => __emp('Confirmed booking email', 'dbem')), 2 => array('title' => __emp('Rejected booking email', 'dbem')), 3 => array('title' => __emp('Booking cancelled', 'dbem'))))));
         //temporary fix, we assume everything is online except for offline - maybe a good reason for split offline/online base gateway subclasses
         if ($gateway == 'offline') {
             $emails[$gateway]['subgroups'][$gateway . '-admin']['emails'][5] = array('title' => __('Awaiting Offline Payment', 'em-pro'));
             $emails[$gateway]['subgroups'][$gateway . '-user']['emails'][5] = array('title' => __('Awaiting Offline Payment', 'em-pro'));
         }
     }
     return $emails;
 }
예제 #11
0
 /**
  * Validates a field and adds errors to the object it's referring to (can be any extension of EM_Object)
  * @param array $field
  * @param mixed $value
  */
 function validate_field($field_id, $value)
 {
     $field = array_key_exists($field_id, $this->form_fields) ? $this->form_fields[$field_id] : false;
     $value = is_array($value) ? $value : trim($value);
     $err = sprintf($this->form_required_error, $field['label']);
     if (is_array($field)) {
         $result = true;
         //innocent until proven guilty
         switch ($field['type']) {
             case 'text':
             case 'textarea':
                 //regex
                 if (trim($value) != '' && !empty($field['options_text_regex']) && !@preg_match('/' . $field['options_text_regex'] . '/', $value)) {
                     $this_err = !empty($field['options_text_error']) ? $field['options_text_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 //non-empty match
                 if ($result && trim($value) == '' && !empty($field['required'])) {
                     $this->add_error($err);
                     $result = false;
                 }
                 break;
             case 'checkbox':
                 //non-empty match
                 if (empty($value) && !empty($field['required'])) {
                     $this_err = !empty($field['options_checkbox_error']) ? $field['options_checkbox_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 break;
             case 'checkboxes':
                 $values = explode("\r\n", $field['options_selection_values']);
                 array_walk($values, 'trim');
                 if (!is_array($value)) {
                     $value = array();
                 }
                 //in-values
                 if (empty($value) && !empty($field['required']) || count(array_diff($value, $values)) > 0) {
                     $this_err = !empty($field['options_selection_error']) ? $field['options_selection_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 break;
             case 'radio':
                 $values = explode("\r\n", $field['options_selection_values']);
                 array_walk($values, 'trim');
                 //in-values
                 if (!empty($value) && !in_array($value, $values) || empty($value) && !empty($field['required'])) {
                     $this_err = !empty($field['options_selection_error']) ? $field['options_selection_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 break;
             case 'multiselect':
                 $values = explode("\r\n", $field['options_select_values']);
                 array_walk($values, 'trim');
                 if (!is_array($value)) {
                     $value = array();
                 }
                 //in_values
                 if (empty($value) && !empty($field['required']) || count(array_diff($value, $values)) > 0) {
                     $this_err = !empty($field['options_select_error']) ? $field['options_select_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 break;
             case 'select':
                 $values = explode("\r\n", $field['options_select_values']);
                 array_walk($values, 'trim');
                 //in-values
                 if (!empty($value) && !in_array($value, $values) || empty($value) && !empty($field['required'])) {
                     $this_err = !empty($field['options_select_error']) ? $field['options_select_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 break;
             case 'country':
                 $values = em_get_countries(__emp('none selected', 'dbem'));
                 //in-values
                 if (!empty($value) && !array_key_exists($value, $values) || empty($value) && !empty($field['required'])) {
                     $this_err = !empty($field['options_select_error']) ? $field['options_select_error'] : $err;
                     $this->add_error($this_err);
                     $result = false;
                 }
                 break;
             case 'date':
                 $dates = !is_array($value) ? explode(',', $value) : $value;
                 $start_date = $dates[0];
                 $end_date = !empty($dates[1]) ? $dates[1] : '';
                 if (!empty($start_date)) {
                     if (preg_match('/\\d{4}-\\d{2}-\\d{2}/', $start_date)) {
                         if ($field['options_date_range']) {
                             if (empty($end_date)) {
                                 $this_err = !empty($field['options_date_error_end']) ? $field['options_date_error_end'] : $this->add_error(__('You must also add an end date.', 'em-pro'));
                                 $this->add_error($this_err);
                                 $result = false;
                             } elseif (!preg_match('/\\d{4}-\\d{2}-\\d{2}/', $end_date)) {
                                 $this_err = !empty($field['options_date_error_format']) ? $field['options_date_error_format'] : __emp('Dates must have correct formatting. Please use the date picker provided.', 'dbem');
                                 $this->add_error($this_err);
                                 $result = false;
                             } else {
                                 //valid end date, check for date order
                                 if (strtotime($start_date) > strtotime($end_date)) {
                                     $this_err = !empty($field['options_date_range_order']) ? $field['options_date_range_order'] : __emp('Please provide a later end date.', 'dbem');
                                     $this->add_error($this_err);
                                     $result = false;
                                 }
                             }
                         }
                     } else {
                         $this_err = !empty($field['options_date_error_format']) ? $field['options_date_error_format'] : __emp('Dates must have correct formatting. Please use the date picker provided.', 'dbem');
                         $this->add_error($this_err);
                         $result = false;
                     }
                 } elseif (!empty($field['required'])) {
                     if ($field['options_date_range'] && !empty($end_date)) {
                         $this_err = !empty($field['options_date_error_start']) ? $field['options_date_error_start'] : $this->add_error(__('You must provide a start date.', 'em-pro'));
                         $this->add_error($this_err);
                         $result = false;
                     } else {
                         $this_err = !empty($field['options_date_error']) ? $field['options_date_error'] : $err;
                         $this->add_error($this_err);
                         $result = false;
                     }
                 }
                 break;
             case 'time':
                 $times = !is_array($value) ? explode(',', $value) : $value;
                 $start_time = $times[0];
                 $end_time = !empty($times[1]) ? $times[1] : '';
                 if (!empty($start_time)) {
                     if (preg_match('/^([01]\\d|2[0-3]):([0-5]\\d) ?(AM|PM)?$/', $start_time)) {
                         if ($field['options_time_range']) {
                             if (empty($end_time)) {
                                 $this_err = !empty($field['options_time_error_end']) ? $field['options_time_error_end'] : $this->add_error(__('You must provide an end time.', 'em-pro'));
                                 $this->add_error($this_err);
                                 $result = false;
                             } elseif (!preg_match('/^([01]\\d|2[0-3]):([0-5]\\d) ?(AM|PM)?$/', $end_time)) {
                                 $this_err = !empty($field['options_time_error_format']) ? $field['options_time_error_format'] : $this->add_error(__('Please use the time picker provided to select the appropriate time format.', 'em-pro'));
                                 $this->add_error($this_err);
                                 $result = false;
                             }
                         }
                     } else {
                         $this_err = !empty($field['options_time_error_format']) ? $field['options_time_error_format'] : __('Please use the time picker provided to select the appropriate time format.', 'em-pro');
                         $this->add_error($this_err);
                         $result = false;
                     }
                 } elseif (!empty($field['required'])) {
                     if ($field['options_time_range'] && !empty($end_time)) {
                         $this_err = !empty($field['options_time_error_start']) ? $field['options_time_error_start'] : $this->add_error(__('You must provide a start time.', 'em-pro'));
                         $this->add_error($this_err);
                         $result = false;
                     } else {
                         $this_err = !empty($field['options_time_error']) ? $field['options_time_error'] : $err;
                         $this->add_error($this_err);
                         $result = false;
                     }
                 }
                 break;
             case 'captcha':
                 if (empty($this->ignore_captcha)) {
                     if (!function_exists('recaptcha_get_html')) {
                         include_once trailingslashit(plugin_dir_path(__FILE__)) . 'includes/lib/recaptchalib.php';
                     }
                     if (function_exists('recaptcha_check_answer') && !is_user_logged_in() && !defined('EMP_CHECKED_CAPTCHA')) {
                         if (!empty($_REQUEST['recaptcha_challenge_field']) && !empty($_REQUEST['recaptcha_response_field'])) {
                             $resp = recaptcha_check_answer($field['options_captcha_key_priv'], $_SERVER['REMOTE_ADDR'], $_REQUEST['recaptcha_challenge_field'], $_REQUEST['recaptcha_response_field']);
                             $result = $resp->is_valid;
                         } else {
                             $result = false;
                             //no request vars submitted
                         }
                         if (!$result) {
                             $err = !empty($field['options_captcha_error']) ? $field['options_captcha_error'] : $err;
                             $this->add_error($err);
                         }
                         define('EMP_CHECKED_CAPTCHA', true);
                         //captchas can only be checked once, and since we only need one captcha per submission....
                     }
                 }
                 break;
             default:
                 //Registration and custom fields
                 $is_manual_booking_new_user = is_user_logged_in() && !empty($_REQUEST['manual_booking']) && wp_verify_nonce($_REQUEST['manual_booking'], 'em_manual_booking_' . $_REQUEST['event_id']) && $_REQUEST['person_id'] == -1;
                 if (array_key_exists($field['type'], $this->user_fields) && self::validate_reg_fields() && self::show_reg_fields($field)) {
                     //preliminary checks/exceptions
                     if (is_user_logged_in() && !get_option('dbem_emp_booking_form_reg_input')) {
                         break;
                     }
                     //add field-specific validation
                     if ($field['type'] == 'user_email') {
                         if (!is_email($value)) {
                             $this->add_error(__emp('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'dbem'));
                             $result = false;
                         } elseif (is_user_logged_in()) {
                             $email_exists = email_exists($value);
                             if ($email_exists && $email_exists != get_current_user_id()) {
                                 $this->add_error(get_option('dbem_booking_feedback_email_exists'));
                                 $result = false;
                             }
                         }
                     }
                     //regex
                     if (trim($value) != '' && !empty($field['options_reg_regex']) && !@preg_match('/' . $field['options_reg_regex'] . '/', $value)) {
                         $this_err = !empty($field['options_reg_error']) ? $field['options_reg_error'] : $err;
                         $this->add_error($this_err);
                         $result = false;
                     }
                     //non-empty match
                     if (empty($value) && !empty($field['required'])) {
                         $this->add_error($err);
                         $result = false;
                     }
                     //custom field chekcs
                     if (array_key_exists($field['type'], $this->custom_user_fields)) {
                         //custom field, so just apply
                         $result = apply_filters('em_form_validate_field_custom', $result, $field, $value, $this);
                     }
                 }
                 break;
         }
     } else {
         $result = false;
     }
     return apply_filters('emp_form_validate_field', $result, $field, $value, $this);
 }