function eme_actions_init() { // first the no cache headers nocache_headers(); eme_load_textdomain(); // now, first update the DB if needed $db_version = get_option('eme_version'); if ($db_version && $db_version != EME_DB_VERSION) { // add possible new options eme_add_options(); // update the DB tables // to do: check if the DB update succeeded ... eme_create_tables(); // now set the version correct update_option('eme_version', EME_DB_VERSION); // let the admin side know if the update succeeded update_option('eme_update_done', 1); } // now first all ajax ops: exit needed if (isset($_GET['eme_ical']) && $_GET['eme_ical'] == 'public_single' && isset($_GET['event_id'])) { header("Content-type: text/calendar; charset=utf-8"); header("Content-Disposition: inline; filename=eme_single.ics"); eme_ical_single(); exit; } if (isset($_GET['eme_ical']) && $_GET['eme_ical'] == 'public') { header("Content-type: text/calendar; charset=utf-8"); header("Content-Disposition: inline; filename=eme_public.ics"); eme_ical(); exit; } if (isset($_POST['eme_ajaxCalendar']) && $_POST['eme_ajaxCalendar'] == true) { header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); eme_filter_calendar_ajax(); exit; } if (isset($_GET['eme_rss']) && $_GET['eme_rss'] == 'main') { header("Content-type: text/xml"); eme_rss(); exit; } if (isset($_POST['eme_ajax_action']) && $_POST['eme_ajax_action'] == 'client_clock_submit') { eme_client_clock_callback(); exit; } if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'booking_data' && is_admin() && isset($_GET['event_id'])) { header("Content-type: application/json; charset=utf-8"); echo '{"bookedSeats":' . eme_get_booked_seats(intval($_GET['event_id'])) . ',"availableSeats":' . eme_get_available_seats(intval($_GET['event_id'])) . '}'; exit; } if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'autocomplete_locations' && is_admin()) { eme_locations_search_ajax(); exit; } if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'autocomplete_people' && is_admin()) { eme_people_search_ajax(); exit; } if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'booking_printable' && is_admin() && isset($_GET['event_id'])) { eme_printable_booking_report(intval($_GET['event_id'])); exit; } if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'booking_csv' && is_admin() && isset($_GET['event_id'])) { eme_csv_booking_report(intval($_GET['event_id'])); exit; } if (is_admin() && current_user_can(get_option('eme_cap_registrations')) && isset($_REQUEST['eme_admin_action']) && $_REQUEST['eme_admin_action'] == 'remove_booking' && isset($_REQUEST['booking_id'])) { $booking_id = intval($_REQUEST['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); if (get_option('eme_deny_mail_event_edit')) { eme_email_rsvp_booking($booking, "denyRegistration"); } // delete the booking answers after the mail is sent, so the answers can still be used in the mail eme_delete_answers($booking_id); exit; } if (isset($_GET['query']) && $_GET['query'] == 'GlobalMapData') { $eventful = isset($_GET['eventful']) ? $_GET['eventful'] : false; $map_id = isset($_GET['map_id']) ? $_GET['map_id'] : 0; $eventful = $eventful === "true" || $eventful === "1" ? true : $eventful; $eventful = $eventful === "false" || $eventful === "0" ? false : $eventful; eme_global_map_json((bool) $eventful, $_GET['scope'], $_GET['category'], $map_id); exit; } if (isset($_GET['eme_eventAction']) && ($_GET['eme_eventAction'] == "paypal_notification" || $_GET['eme_eventAction'] == "paypal_ipn")) { eme_paypal_notification(); exit; } if (isset($_GET['eme_eventAction']) && ($_GET['eme_eventAction'] == "2co_notification" || $_GET['eme_eventAction'] == "2co_ins")) { eme_2co_notification(); exit; } if (isset($_GET['eme_eventAction']) && $_GET['eme_eventAction'] == "webmoney_notification") { eme_webmoney_notification(); exit; } if (isset($_GET['eme_eventAction']) && $_GET['eme_eventAction'] == "mollie_notification") { eme_mollie_notification(); exit; } if (isset($_POST['eme_eventAction']) && ($_POST['eme_eventAction'] == "fdgg_notification" || $_POST['eme_eventAction'] == "fdgg_ipn")) { eme_fdgg_notification(); exit; } if (isset($_GET['eme_eventAction']) && $_GET['eme_eventAction'] == "worldpay_notification") { eme_worldpay_notification(); exit; } if (isset($_GET['eme_eventAction']) && $_GET['eme_eventAction'] == "sagepay_notification") { eme_sagepay_notification(); // sagepay doesn't use a notification url, but sends the status along as part of the return url, so we just check // the status and set payed or not, but then we continue regular flow of events } }
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; } }
function eme_registration_seats_page($pending = 0) { global $wpdb, $plugin_page; // do the actions if required if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == "editRegistration" && isset($_GET['booking_id'])) { $booking_id = intval($_GET['booking_id']); $booking = eme_get_booking($booking_id); $event_id = $booking['event_id']; $event = eme_get_event($event_id); // we need to set the action url, otherwise the GET parameters stay and we will fall in this if-statement all over again $action_url = admin_url("admin.php?page={$plugin_page}"); $ret_string = "<form id='eme-rsvp-form' name='booking-form' method='post' action='{$action_url}'>"; $ret_string .= __('Send mails for changed registration?', 'eme') . eme_ui_select_binary(1, "send_mail"); $ret_string .= eme_replace_formfields_placeholders($event, $booking); $ret_string .= "\n <input type='hidden' name='eme_admin_action' value='updateRegistration' />\n <input type='hidden' name='booking_id' value='{$booking_id}' />\n </form>"; print $ret_string; return; } else { $action = isset($_POST['eme_admin_action']) ? $_POST['eme_admin_action'] : ''; $send_mail = isset($_POST['send_mail']) ? intval($_POST['send_mail']) : 1; if ($action == 'newRegistration') { $event_id = intval($_POST['event_id']); $event = eme_get_event($event_id); $ret_string = "<form id='eme-rsvp-form' name='booking-form' method='post' action=''>"; $ret_string .= __('Send mails for new registration?', 'eme') . eme_ui_select_binary(1, "send_mail"); $ret_string .= eme_replace_formfields_placeholders($event); $ret_string .= "\n <input type='hidden' name='eme_admin_action' value='addRegistration' />\n <input type='hidden' name='event_id' value='{$event_id}' />\n </form>"; print $ret_string; return; } elseif ($action == 'addRegistration') { $event_id = intval($_POST['event_id']); $booking_payed = isset($_POST['booking_payed']) ? intval($_POST['booking_payed']) : 0; $event = eme_get_event($event_id); $booking_res = eme_book_seats($event, $send_mail); $result = $booking_res[0]; $booking_id_done = $booking_res[1]; if (!$booking_id_done) { print "<div id='message' class='error'><p>{$result}</p></div>"; } else { print "<div id='message' class='updated'><p>{$result}</p></div>"; eme_update_booking_payed($booking_id_done, $booking_payed); } } elseif ($action == 'updateRegistration') { $booking_id = intval($_POST['booking_id']); $booking = eme_get_booking($booking_id); $deprecated = get_option('eme_deprecated'); //$event_id = $booking['event_id']; //$event = eme_get_event($event_id); if (isset($_POST['comment'])) { $bookerComment = eme_strip_tags($_POST['comment']); } else { $bookerComment = ""; } if (isset($_POST['bookedSeats'])) { $bookedSeats = intval($_POST['bookedSeats']); } else { $bookedSeats = 0; } // for multiple prices, we have multiple booked Seats as well // the next foreach is only valid when called from the frontend $bookedSeats_mp = array(); //if (eme_is_multi($event['price'])) { if (eme_is_multi($booking['booking_price'])) { // make sure the array contains the correct keys already, since // later on in the function eme_record_booking we do a join //$booking_prices_mp=eme_convert_multi2array($event['price']); $booking_prices_mp = eme_convert_multi2array($booking['booking_price']); foreach ($booking_prices_mp as $key => $value) { $bookedSeats_mp[$key] = 0; } foreach ($_POST as $key => $value) { if (preg_match('/bookedSeats(\\d+)/', $key, $matches)) { $field_id = intval($matches[1]) - 1; $bookedSeats += $value; $bookedSeats_mp[$field_id] = $value; } } eme_update_booking($booking_id, $booking['event_id'], eme_convert_array2multi($bookedSeats_mp), $booking['booking_price'], $bookerComment); } else { eme_update_booking($booking_id, $booking['event_id'], $bookedSeats, $booking['booking_price'], $bookerComment); } eme_update_person_with_postinfo($booking['person_id']); if ($send_mail) { eme_email_rsvp_booking($booking, $action); } print "<div id='message' class='updated'><p>" . __("Booking updated", "eme") . "</p></div>"; } elseif ($action == 'approveRegistration' || $action == 'denyRegistration' || $action == 'updatePayedStatus') { $bookings = isset($_POST['bookings']) ? $_POST['bookings'] : array(); $selected_bookings = isset($_POST['selected_bookings']) ? $_POST['selected_bookings'] : array(); $bookings_seats = isset($_POST['bookings_seats']) ? $_POST['bookings_seats'] : array(); $bookings_payed = isset($_POST['bookings_payed']) ? $_POST['bookings_payed'] : array(); foreach ($bookings as $key => $booking_id) { if (!in_array($booking_id, $selected_bookings)) { continue; } // make sure the seats are integers $booking = eme_get_booking($booking_id); if ($action == 'updatePayedStatus') { if ($booking['booking_payed'] != intval($bookings_payed[$key])) { eme_update_booking_payed($booking_id, intval($bookings_payed[$key])); } } elseif ($action == 'approveRegistration') { eme_approve_booking($booking_id); if ($booking['booking_payed'] != intval($bookings_payed[$key])) { eme_update_booking_payed($booking_id, intval($bookings_payed[$key])); } if ($send_mail) { eme_email_rsvp_booking($booking, $action); } } elseif ($action == 'denyRegistration') { eme_delete_booking($booking_id); if ($send_mail) { eme_email_rsvp_booking($booking, $action); } } } } } // now show the menu eme_registration_seats_form_table($pending); }
function eme_registration_seats_page($pending=0) { global $wpdb,$plugin_page,$eme_timezone; // do the actions if required if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == "editRegistration" && isset($_GET['booking_id'])) { $booking_id = intval($_GET['booking_id']); $booking = eme_get_booking($booking_id); $event_id = $booking['event_id']; $event = eme_get_event($event_id); // we need to set the action url, otherwise the GET parameters stay and we will fall in this if-statement all over again $action_url = admin_url("admin.php?page=$plugin_page"); $ret_string = "<form id='eme-rsvp-form' name='booking-form' method='post' action='$action_url'>"; $ret_string.= __('Send mails for changed registration?','eme') . eme_ui_select_binary(1,"send_mail"); $all_events = eme_get_events("extra_conditions=".urlencode("event_rsvp=1 AND event_id!=$event_id")); if (count($all_events)>0) { $ret_string.= "<br />".__('Move booking to event','eme'); $ret_string.= " <select name='event_id'>"; $ret_string.= "<option value='0' ></option>"; foreach ( $all_events as $this_event ) { if ($this_event ['event_rsvp']) { $option_text=$this_event['event_name']." (".eme_localised_date($this_event['event_start_date']." ".$this_event['event_start_time']." ".$eme_timezone).")"; $ret_string.= "<option value='".$this_event['event_id']."' >".$option_text."</option>"; } } $ret_string .= "</select>"; } $ret_string.= eme_replace_formfields_placeholders ($event,$booking); $ret_string .= " <input type='hidden' name='eme_admin_action' value='updateRegistration' /> <input type='hidden' name='booking_id' value='$booking_id' /> </form>"; print $ret_string; return; } else { $action = isset($_POST ['eme_admin_action']) ? $_POST ['eme_admin_action'] : ''; $send_mail = isset($_POST ['send_mail']) ? intval($_POST ['send_mail']) : 1; if ($action == 'newRegistration') { $event_id = intval($_POST['event_id']); $event = eme_get_event($event_id); $ret_string = "<form id='eme-rsvp-form' name='booking-form' method='post' action=''>"; $ret_string.= __('Send mails for new registration?','eme') . eme_ui_select_binary(1,"send_mail"); $ret_string.= eme_replace_formfields_placeholders ($event); $ret_string .= " <input type='hidden' name='eme_admin_action' value='addRegistration' /> <input type='hidden' name='event_id' value='$event_id' /> </form>"; print $ret_string; return; } elseif ($action == 'addRegistration') { $event_id = intval($_POST['event_id']); $booking_payed = isset($_POST ['booking_payed']) ? intval($_POST ['booking_payed']) : 0; $event = eme_get_event($event_id); $booking_res = eme_book_seats($event, $send_mail); $result=$booking_res[0]; $booking_id_done=$booking_res[1]; if (!$booking_id_done) { print "<div id='message' class='error'><p>$result</p></div>"; } else { print "<div id='message' class='updated'><p>$result</p></div>"; eme_update_booking_payed($booking_id_done,$booking_payed); } } elseif ($action == 'updateRegistration') { $booking_id = intval($_POST['booking_id']); $event_id = isset($_POST ['event_id']) ? intval($_POST ['event_id']) : 0; if ($event_id) eme_move_booking_event($booking_id,$event_id); $booking = eme_get_booking ($booking_id); if (isset($_POST['comment'])) $bookerComment = eme_strip_tags($_POST['comment']); else $bookerComment = ""; if (isset($_POST['bookedSeats'])) $bookedSeats = intval($_POST['bookedSeats']); else $bookedSeats = 0; // for multiple prices, we have multiple booked Seats as well // the next foreach is only valid when called from the frontend $bookedSeats_mp = array(); //if (eme_is_multi($event['price'])) { if (eme_is_multi($booking['booking_price'])) { // make sure the array contains the correct keys already, since // later on in the function eme_record_booking we do a join //$booking_prices_mp=eme_convert_multi2array($event['price']); $booking_prices_mp=eme_convert_multi2array($booking['booking_price']); foreach ($booking_prices_mp as $key=>$value) { $bookedSeats_mp[$key] = 0; } foreach($_POST as $key=>$value) { if (preg_match('/bookedSeats(\d+)/', $key, $matches)) { $field_id = intval($matches[1])-1; $bookedSeats += $value; $bookedSeats_mp[$field_id]=$value; } } eme_update_booking($booking_id,$booking['event_id'],eme_convert_array2multi($bookedSeats_mp),$booking['booking_price'],$bookerComment); } else { eme_update_booking($booking_id,$booking['event_id'],$bookedSeats,$booking['booking_price'],$bookerComment); } eme_update_person_with_postinfo($booking['person_id']); // now get the changed booking and send mail if wanted $booking = eme_get_booking ($booking_id); if ($send_mail) eme_email_rsvp_booking($booking,$action); print "<div id='message' class='updated'><p>".__("Booking updated","eme")."</p></div>"; } elseif ($action == 'approveRegistration' || $action == 'denyRegistration' || $action == 'updatePayedStatus') { $bookings = isset($_POST ['bookings']) ? $_POST ['bookings'] : array(); $selected_bookings = isset($_POST ['selected_bookings']) ? $_POST ['selected_bookings'] : array(); $bookings_seats = isset($_POST ['bookings_seats']) ? $_POST ['bookings_seats'] : array(); $bookings_payed = isset($_POST ['bookings_payed']) ? $_POST ['bookings_payed'] : array(); foreach ( $bookings as $key=>$booking_id ) { if (!in_array($booking_id,$selected_bookings)) { continue; } // make sure the seats are integers $booking = eme_get_booking ($booking_id); if ($action == 'updatePayedStatus') { if ($booking['booking_payed']!= intval($bookings_payed[$key])) eme_update_booking_payed($booking_id,intval($bookings_payed[$key])); } elseif ($action == 'approveRegistration') { eme_approve_booking($booking_id); if ($booking['booking_payed']!= intval($bookings_payed[$key])) { eme_update_booking_payed($booking_id,intval($bookings_payed[$key])); // we changed something in the booking, so get the updated booking // before sending out the mail $booking = eme_get_booking ($booking_id); } if ($send_mail) eme_email_rsvp_booking($booking,$action); } elseif ($action == 'denyRegistration') { // the mail needs to be sent after the deletion, otherwise the count of free spaces is wrong eme_delete_booking($booking_id); if ($send_mail) eme_email_rsvp_booking($booking,$action); // delete the booking answers after the mail is sent, so the answers can still be used in the mail eme_delete_answers($booking_id); } } } } // now show the menu eme_registration_seats_form_table($pending); }