Beispiel #1
0
function eme_send_mails_page()
{
    global $wpdb;
    $event_id = isset($_POST['event_id']) ? intval($_POST['event_id']) : 0;
    $action = isset($_POST['eme_admin_action']) ? $_POST['eme_admin_action'] : '';
    $onchange = isset($_POST['onchange']) ? intval($_POST['onchange']) : 0;
    if (isset($_POST['mail_subject']) && !empty($_POST['mail_subject'])) {
        $mail_subject = stripslashes_deep($_POST['mail_subject']);
    } elseif (isset($_POST['subject_template']) && intval($_POST['subject_template']) > 0) {
        $mail_subject = eme_get_template_format(intval($_POST['subject_template']));
    } else {
        $mail_subject = "";
    }
    if (isset($_POST['mail_message']) && !empty($_POST['mail_message'])) {
        $mail_message = stripslashes_deep($_POST['mail_message']);
    } elseif (isset($_POST['message_template']) && intval($_POST['message_template']) > 0) {
        $mail_message = eme_get_template_format(intval($_POST['message_template']));
    } else {
        $mail_message = "";
    }
    if (!$onchange && $event_id > 0 && $action == 'send_mail') {
        $pending_approved = isset($_POST['pending_approved']) ? $_POST['pending_approved'] : 0;
        $only_unpayed = isset($_POST['only_unpayed']) ? $_POST['only_unpayed'] : 0;
        $eme_mail_type = isset($_POST['eme_mail_type']) ? $_POST['eme_mail_type'] : 'attendees';
        if (empty($mail_subject) || empty($mail_message)) {
            print "<div id='message' class='error'><p>" . __('Please enter both subject and message for the mail to be sent.', 'eme') . "</p></div>";
        } else {
            $event = eme_get_event($event_id);
            $current_userid = get_current_user_id();
            if (current_user_can(get_option('eme_cap_send_other_mails')) || current_user_can(get_option('eme_cap_send_mails')) && ($event['event_author'] == $current_userid || $event['event_contactperson_id'] == $current_userid)) {
                $event_name = $event['event_name'];
                $contact = eme_get_contact($event);
                $contact_email = $contact->user_email;
                $contact_name = $contact->display_name;
                $mail_text_html = get_option('eme_rsvp_send_html') ? "html" : "text";
                if ($eme_mail_type == 'attendees') {
                    $attendees = eme_get_attendees_for($event_id, $pending_approved, $only_unpayed);
                    foreach ($attendees as $attendee) {
                        $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text", 0, $attendee['lang']);
                        $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html, 0, $attendee['lang']);
                        $tmp_subject = eme_replace_attendees_placeholders($tmp_subject, $event, $attendee, "text", 0, $attendee['lang']);
                        $tmp_message = eme_replace_attendees_placeholders($tmp_message, $event, $attendee, $mail_text_html, 0, $attendee['lang']);
                        $tmp_subject = eme_translate($tmp_subject, $attendee['lang']);
                        $tmp_message = eme_translate($tmp_message, $attendee['lang']);
                        $person_name = $attendee['lastname'] . ' ' . $attendee['firstname'];
                        eme_send_mail($tmp_subject, $tmp_message, $attendee['email'], $person_name, $contact_email, $contact_name);
                    }
                } elseif ($eme_mail_type == 'bookings') {
                    $bookings = eme_get_bookings_for($event_id, $pending_approved, $only_unpayed);
                    foreach ($bookings as $booking) {
                        // we use the language done in the booking for the mails, not the attendee lang in this case
                        $attendee = eme_get_person($booking['person_id']);
                        if ($attendee && is_array($attendee)) {
                            $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text", 0, $booking['lang']);
                            $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html, 0, $booking['lang']);
                            $tmp_subject = eme_replace_booking_placeholders($tmp_subject, $event, $booking, "text", 0, $booking['lang']);
                            $tmp_message = eme_replace_booking_placeholders($tmp_message, $event, $booking, $mail_text_html, 0, $booking['lang']);
                            $tmp_subject = eme_translate($tmp_subject, $booking['lang']);
                            $tmp_message = eme_translate($tmp_message, $booking['lang']);
                            $person_name = $attendee['lastname'] . ' ' . $attendee['firstname'];
                            eme_send_mail($tmp_subject, $tmp_message, $attendee['email'], $person_name, $contact_email, $contact_name);
                        }
                    }
                } elseif ($eme_mail_type == 'all_wp') {
                    $wp_users = get_users();
                    $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text");
                    $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html);
                    foreach ($wp_users as $wp_user) {
                        eme_send_mail($tmp_subject, $tmp_message, $wp_user->user_email, $wp_user->display_name, $contact_email, $contact_name);
                    }
                } elseif ($eme_mail_type == 'all_wp_not_registered') {
                    $wp_users = get_users();
                    $attendee_wp_ids = eme_get_wp_ids_for($event_id);
                    $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text");
                    $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html);
                    foreach ($wp_users as $wp_user) {
                        if (!in_array($wp_user->ID, $attendee_wp_ids)) {
                            eme_send_mail($tmp_subject, $tmp_message, $wp_user->user_email, $wp_user->display_name, $contact_email, $contact_name);
                        }
                    }
                }
                print "<div id='message' class='updated'><p>" . __('The mail has been sent.', 'eme') . "</p></div>";
            } else {
                print "<div id='message' class='error'><p>" . __('You do not have the permission to send mails for this event.', 'eme') . "</p></div>";
            }
        }
    }
    // now show the form
    eme_send_mail_form($event_id);
}
function eme_multipayment_form($payment_id, $form_result_message = "")
{
    $ret_string = "<div id='eme-rsvp-message'>";
    if (!empty($form_result_message)) {
        $ret_string .= "<div class='eme-rsvp-message'>{$form_result_message}</div>";
    }
    $ret_string .= "</div>";
    $booking_ids = eme_get_payment_booking_ids($payment_id);
    if (!$booking_ids) {
        return $ret_string;
    }
    $bookings = eme_get_bookings($booking_ids);
    $total_price = eme_bookings_total_booking_price($bookings);
    // we take the currency of the first event in the series
    $event = eme_get_event_by_booking_id($booking_ids[0]);
    $booking = eme_get_booking($booking_ids[0]);
    $cur = $event['currency'];
    $eme_multipayment_form_header_format = get_option('eme_multipayment_form_header_format');
    if (!empty($eme_multipayment_form_header_format)) {
        $result = eme_replace_placeholders($eme_multipayment_form_header_format, $event, "html", 0);
        $result = eme_replace_booking_placeholders($result, $event, $booking);
        $ret_string .= "<div id='eme-payment-formtext' class='eme-payment-formtext'>";
        $ret_string .= $result;
        $ret_string .= "</div>";
    } else {
        $ret_string .= "<div id='eme-payment-handling' class='eme-payment-handling'>" . __('Payment handling', 'eme') . "</div>";
        $ret_string .= "<div id='eme-payment-price-info' class='eme-payment-price-info'>" . sprintf(__("The booking price in %s is: %01.2f", 'eme'), $cur, $total_price) . "</div>";
    }
    $ret_string .= "<div id='eme-payment-form' class='eme-payment-form'>";
    $payment = eme_get_payment($payment_id);
    if ($event['use_paypal']) {
        $ret_string .= eme_paypal_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    if ($event['use_2co']) {
        $ret_string .= eme_2co_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    if ($event['use_webmoney']) {
        $ret_string .= eme_webmoney_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    if ($event['use_fdgg']) {
        $ret_string .= eme_fdgg_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    if ($event['use_mollie']) {
        $ret_string .= eme_mollie_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    if ($event['use_sagepay']) {
        $ret_string .= eme_sagepay_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    if ($event['event_properties']['use_worldpay']) {
        $ret_string .= eme_worldpay_form($event, $payment, $total_price, $booking['lang'], 1);
    }
    $ret_string .= "</div>";
    $eme_multipayment_form_footer_format = get_option('eme_multipayment_form_footer_format');
    if (!empty($eme_multipayment_form_footer_format)) {
        $result = eme_replace_placeholders($eme_multipayment_form_footer_format, $event, "html", 0);
        $result = eme_replace_booking_placeholders($result, $event, $booking);
        $ret_string .= "<div id='eme-payment-formtext' class='eme-payment-formtext'>";
        $ret_string .= $result;
        $ret_string .= "</div>";
    }
    return $ret_string;
}
Beispiel #3
0
function eme_events_page_content()
{
    global $wpdb;
    $format_header = get_option('eme_event_list_item_format_header');
    if (empty($format_header)) {
        $format_header = DEFAULT_EVENT_LIST_HEADER_FORMAT;
    }
    $format_footer = get_option('eme_event_list_item_format_footer');
    if (empty($format_footer)) {
        $format_footer = DEFAULT_EVENT_LIST_FOOTER_FORMAT;
    }
    if (isset($_REQUEST['eme_cancel_booking'])) {
        // GET for cancel links, POST for the cancel form
        $payment_randomid = eme_strip_tags($_REQUEST['eme_cancel_booking']);
        return eme_cancel_confirm_form($payment_randomid);
    } elseif (isset($_POST['eme_confirm_cancel_booking']) && isset($_POST['eme_pmt_rndid'])) {
        $payment_randomid = eme_strip_tags($_POST['eme_pmt_rndid']);
        $payment = eme_get_payment(0, $payment_randomid);
        $booking_ids = eme_get_payment_booking_ids($payment['id']);
        if (isset($_POST['eme_rsvp_nonce']) && wp_verify_nonce($_POST['eme_rsvp_nonce'], "cancel booking {$payment_randomid}")) {
            foreach ($booking_ids as $booking_id) {
                $booking = eme_get_booking($booking_id);
                // delete the booking before the mail is sent, so free spaces are correct
                eme_delete_booking($booking_id);
                eme_email_rsvp_booking($booking, "cancelRegistration");
                // delete the booking answers after the mail is sent, so the answers can still be used in the mail
                eme_delete_answers($booking_id);
            }
            eme_delete_payment($payment['id']);
        }
        return "<div class='eme-rsvp-message'>" . __("The bookings have been cancelled", 'eme') . "</div>";
    } elseif (get_query_var('eme_pmt_result') && get_option('eme_payment_show_custom_return_page')) {
        // show the result of a payment, but not for a multi-booking payment result
        $result = get_query_var('eme_pmt_result');
        if ($result == 'succes') {
            $format = get_option('eme_payment_succes_format');
        } else {
            $format = get_option('eme_payment_fail_format');
        }
        if (get_option('eme_payment_add_bookingid_to_return') && get_query_var('eme_pmt_id') && get_query_var('event_id')) {
            $event = eme_get_event(intval(get_query_var('event_id')));
            $payment_id = intval(get_query_var('eme_pmt_id'));
            $booking_ids = eme_get_payment_booking_ids($payment_id);
            if ($booking_ids) {
                // since each booking is for a different event, we can't know which one to show
                // so we show only the first one
                $booking = eme_get_booking($booking_ids[0]);
                return eme_replace_booking_placeholders($format, $event, $booking);
            } else {
                return;
            }
        } elseif (get_query_var('event_id')) {
            $event = eme_get_event(intval(get_query_var('event_id')));
            return eme_replace_placeholders($format, $event);
        } else {
            return $format;
        }
    } elseif (get_query_var('eme_pmt_id')) {
        $payment_id = intval(get_query_var('eme_pmt_id'));
        $booking_ids = eme_get_payment_booking_ids($payment_id);
        if (count($booking_ids) == 1) {
            $page_body = eme_payment_form("", $payment_id);
        } else {
            $page_body = eme_multipayment_form($payment_id);
        }
        return $page_body;
    }
    if (get_query_var('eme_town')) {
        $eme_town = eme_sanitize_request(get_query_var('eme_town'));
        $location_ids = join(',', eme_get_town_location_ids($eme_town));
        $stored_format = get_option('eme_event_list_item_format');
        if (count($location_ids) > 0) {
            $format_header = get_option('eme_location_list_item_format_header');
            if (empty($format_header)) {
                $format_header = DEFAULT_EVENT_LIST_HEADER_FORMAT;
            }
            $format_footer = get_option('eme_location_list_item_format_footer');
            if (empty($format_footer)) {
                $format_footer = DEFAULT_EVENT_LIST_FOOTER_FORMAT;
            }
            $page_body = eme_get_events_list(get_option('eme_event_list_number_items'), "future", "ASC", $stored_format, $format_header, $format_footer, 0, '', '', 0, '', '', 0, $location_ids);
        } else {
            $page_body = "<div id='events-no-events'>" . get_option('eme_no_events_message') . "</div>";
        }
        return $page_body;
    }
    if (get_query_var('location_id')) {
        $location = eme_get_location(intval(get_query_var('location_id')));
        $single_location_format = get_option('eme_single_location_format');
        $page_body = eme_replace_locations_placeholders($single_location_format, $location);
        return $page_body;
    }
    if (!get_query_var('calendar_day') && get_query_var('eme_event_cat')) {
        $format_header = get_option('eme_cat_event_list_item_format_header');
        if (empty($format_header)) {
            $format_header = DEFAULT_CAT_EVENT_LIST_HEADER_FORMAT;
        }
        $format_footer = get_option('eme_cat_event_list_item_format_footer');
        if (empty($format_footer)) {
            $format_footer = DEFAULT_CAT_EVENT_LIST_FOOTER_FORMAT;
        }
        $eme_event_cat = eme_sanitize_request(get_query_var('eme_event_cat'));
        $cat_ids = join(',', eme_get_category_ids($eme_event_cat));
        $stored_format = get_option('eme_event_list_item_format');
        if (!empty($cat_ids)) {
            $page_body = eme_get_events_list(get_option('eme_event_list_number_items'), "future", "ASC", $stored_format, $format_header, $format_footer, 0, $cat_ids);
        } else {
            $page_body = "<div id='events-no-events'>" . get_option('eme_no_events_message') . "</div>";
        }
        return $page_body;
    }
    //if (isset ( $_REQUEST['event_id'] ) && $_REQUEST['event_id'] != '') {
    if (eme_is_single_event_page()) {
        // single event page
        $event_id = intval(get_query_var('event_id'));
        return eme_display_single_event($event_id);
    } elseif (get_query_var('calendar_day')) {
        $scope = eme_sanitize_request(get_query_var('calendar_day'));
        $location_id = isset($_GET['location_id']) ? urldecode($_GET['location_id']) : '';
        $category = isset($_GET['category']) ? urldecode($_GET['category']) : '';
        $notcategory = isset($_GET['notcategory']) ? urldecode($_GET['notcategory']) : '';
        $author = isset($_GET['author']) ? urldecode($_GET['author']) : '';
        $contact_person = isset($_GET['contact_person']) ? urldecode($_GET['contact_person']) : '';
        $event_list_item_format = get_option('eme_event_list_item_format');
        $show_single_event = 1;
        $page_body = eme_get_events_list(0, $scope, "ASC", $event_list_item_format, $format_header, $format_footer, $location_id, $category, '', 0, $author, $contact_person, 0, '', 0, 1, 0, $notcategory, 0, 0, 0, 0, "", $show_single_event);
        return $page_body;
    } else {
        // Multiple events page
        isset($_GET['scope']) ? $scope = eme_sanitize_request($_GET['scope']) : ($scope = "future");
        $stored_format = get_option('eme_event_list_item_format');
        if (get_option('eme_display_calendar_in_events_page')) {
            $page_body = eme_get_calendar('full=1');
        } else {
            $page_body = eme_get_events_list(get_option('eme_event_list_number_items'), $scope, "ASC", $stored_format, $format_header, $format_footer, 0);
        }
        return $page_body;
    }
}