function rsvp_frontend_greeting() { global $rsvp_form_action; $customGreeting = get_option(OPTION_GREETING); if (rsvp_require_only_passcode_to_register()) { $output = RSVP_START_PARA . __("Please enter your passcode to RSVP.", 'rsvp-plugin') . RSVP_END_PARA; } else { if (rsvp_require_passcode()) { $output = RSVP_START_PARA . __("Please enter your first name, last name and passcode to RSVP.", 'rsvp-plugin') . RSVP_END_PARA; } else { $output = RSVP_START_PARA . __("Please enter your first and last name to RSVP.", 'rsvp-plugin') . RSVP_END_PARA; } } $firstName = ""; $lastName = ""; $passcode = ""; if (isset($_SESSION['rsvpFirstName'])) { $firstName = $_SESSION['rsvpFirstName']; } if (isset($_SESSION['rsvpLastName'])) { $lastName = $_SESSION['rsvpLastName']; } if (isset($_SESSION['rsvpPasscode'])) { $passcode = $_SESSION['rsvpPasscode']; } if (!empty($customGreeting)) { $output = RSVP_START_PARA . nl2br($customGreeting) . RSVP_END_PARA; } $output .= RSVP_START_CONTAINER; if (get_option(OPTION_RSVP_OPEN_REGISTRATION) == "Y") { $output .= "<form name=\"rsvpNew\" method=\"post\" id=\"rsvpNew\" action=\"{$rsvp_form_action}\">\r\n"; $output .= "\t<input type=\"hidden\" name=\"rsvpStep\" value=\"newattendee\" />"; $output .= "<input type=\"submit\" value=\"" . __("New Attendee Registration", "rsvp-plugin") . "\" />\r\n"; $output .= "</form>\r\n"; $output .= "<hr />"; $output .= RSVP_START_PARA . __("Need to modify your registration? Start with the below form.", "rsvp-plugin") . RSVP_END_PARA; } $output .= "<form name=\"rsvp\" method=\"post\" id=\"rsvp\" action=\"{$rsvp_form_action}\" autocomplete=\"off\">\r\n"; $output .= "\t<input type=\"hidden\" name=\"rsvpStep\" value=\"find\" />"; if (!rsvp_require_only_passcode_to_register()) { $output .= RSVP_START_PARA . "<label for=\"firstName\">" . __("First Name", 'rsvp-plugin') . ":</label> \n\t\t\t\t\t\t\t\t <input type=\"text\" name=\"firstName\" id=\"firstName\" size=\"30\" value=\"" . htmlspecialchars($firstName) . "\" class=\"required\" />" . RSVP_END_PARA; $output .= RSVP_START_PARA . "<label for=\"lastName\">" . __("Last Name", 'rsvp-plugin') . ":</label> \n\t\t\t\t\t\t\t\t <input type=\"text\" name=\"lastName\" id=\"lastName\" size=\"30\" value=\"" . htmlspecialchars($lastName) . "\" class=\"required\" />" . RSVP_END_PARA; } if (rsvp_require_passcode()) { $output .= RSVP_START_PARA . "<label for=\"passcode\">" . __("Passcode", 'rsvp-plugin') . ":</label> \n\t\t\t\t\t\t\t\t\t <input type=\"password\" name=\"passcode\" id=\"passcode\" size=\"30\" value=\"" . htmlspecialchars($passcode) . "\" class=\"required\" autocomplete=\"off\" />" . RSVP_END_PARA; } $output .= RSVP_START_PARA . "<input type=\"submit\" value=\"" . __("Complete your RSVP!", 'rsvp-plugin') . "\" />" . RSVP_END_PARA; $output .= "</form>\r\n"; $output .= RSVP_END_CONTAINER; return $output; }
function rsvp_require_unique_passcode() { return rsvp_require_only_passcode_to_register(); }
function rsvp_admin_export() { global $wpdb; $customLinkBase = ""; // Get page associated with the page to build out prefill link. $query = new WP_Query('s=rsvp-pluginhere'); if ($query->have_posts()) { $query->the_post(); $customLinkBase = get_permalink(); if (strpos($customLinkBase, "?") !== false) { $customLinkBase .= "&"; } else { $customLinkBase .= "?"; } if (rsvp_require_only_passcode_to_register()) { $customLinkBase .= "passcode=%s"; } else { $customLinkBase .= "firstName=%s&lastName=%s"; if (rsvp_require_passcode()) { $customLinkBase .= "&passcode=%s"; } } } wp_reset_postdata(); $sql = "SELECT id, firstName, lastName, email, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal, passcode \n\t\t\t\t\t\t\tFROM " . ATTENDEES_TABLE; $orderBy = " lastName, firstName"; if (isset($_POST['sortValue'])) { if (strToLower($_POST['sortValue']) == "rsvpstatus") { $orderBy = " rsvpStatus " . (strtolower($_POST['exportSortDirection']) == "desc" ? "DESC" : "ASC") . ", " . $orderBy; } else { if (strToLower($_POST['sortValue']) == "attendee") { $direction = strtolower($_POST['exportSortDirection']) == "desc" ? "DESC" : "ASC"; $orderBy = " lastName {$direction}, firstName {$direction}"; } else { if (strToLower($_POST['sortValue']) == "kidsmeal") { $orderBy = " kidsMeal " . (strtolower($_POST['exportSortDirection']) == "desc" ? "DESC" : "ASC") . ", " . $orderBy; } else { if (strToLower($_POST['sortValue']) == "additional") { $orderBy = " additionalAttendee " . (strtolower($_POST['exportSortDirection']) == "desc" ? "DESC" : "ASC") . ", " . $orderBy; } else { if (strToLower($_POST['sortValue']) == "vegetarian") { $orderBy = " veggieMeal " . (strtolower($_POST['exportSortDirection']) == "desc" ? "DESC" : "ASC") . ", " . $orderBy; } } } } } } $sql .= " ORDER BY " . $orderBy; $attendees = $wpdb->get_results($sql); $csv = "\"" . __("Attendee", 'rsvp-plugin') . "\",\"" . __("Email", 'rsvp-plugin') . "\",\"" . __("RSVP Status", 'rsvp-plugin') . "\","; if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { $csv .= "\"" . __("Kids Meal", 'rsvp-plugin') . "\","; } $csv .= "\"" . __("Additional Attendee", 'rsvp-plugin') . "\","; if (get_option(OPTION_HIDE_VEGGIE) != "Y") { $csv .= "\"" . __("Vegatarian", 'rsvp-plugin') . "\","; } if (rsvp_require_passcode()) { $csv .= "\"" . __("Passcode", 'rsvp-plugin') . "\","; } $csv .= "\"" . __("Note", 'rsvp-plugin') . "\",\"" . __("Associated Attendees", 'rsvp-plugin') . "\""; $qRs = $wpdb->get_results("SELECT id, question FROM " . QUESTIONS_TABLE . " ORDER BY sortOrder, id"); if (count($qRs) > 0) { foreach ($qRs as $q) { $csv .= ",\"" . stripslashes($q->question) . "\""; } } $csv .= ",\"" . __("pre-fill URL", 'rsvp-plugin') . "\""; $csv .= "\r\n"; foreach ($attendees as $a) { $csv .= "\"" . stripslashes($a->firstName . " " . $a->lastName) . "\",\"" . stripslashes($a->email) . "\",\"" . $a->rsvpStatus . "\","; if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { $csv .= "\"" . ($a->kidsMeal == "Y" ? __("Yes", 'rsvp-plugin') : __("No", 'rsvp-plugin')) . "\","; } $csv .= "\"" . ($a->additionalAttendee == "Y" ? __("Yes", 'rsvp-plugin') : __("No", 'rsvp-plugin')) . "\","; if (get_option(OPTION_HIDE_VEGGIE) != "Y") { $csv .= "\"" . ($a->veggieMeal == "Y" ? __("Yes", 'rsvp-plugin') : __("No", 'rsvp-plugin')) . "\","; } if (rsvp_require_passcode()) { $csv .= "\"" . $a->passcode . "\","; } $csv .= "\"" . str_replace("\"", "\"\"", stripslashes($a->note)) . "\",\""; $sql = "SELECT firstName, lastName FROM " . ATTENDEES_TABLE . " \n\t\t\t\t \tWHERE id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\t\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d)"; $associations = $wpdb->get_results($wpdb->prepare($sql, $a->id, $a->id)); foreach ($associations as $assc) { $csv .= trim(stripslashes($assc->firstName . " " . $assc->lastName)) . "\r\n"; } $csv .= "\""; $qRs = $wpdb->get_results("SELECT id, question FROM " . QUESTIONS_TABLE . " ORDER BY sortOrder, id"); if (count($qRs) > 0) { foreach ($qRs as $q) { $aRs = $wpdb->get_results($wpdb->prepare("SELECT answer FROM " . ATTENDEE_ANSWERS . " WHERE attendeeID = %d AND questionID = %d", $a->id, $q->id)); if (count($aRs) > 0) { $csv .= ",\"" . stripslashes($aRs[0]->answer) . "\""; } else { $csv .= ",\"\""; } } } if (empty($customLinkBase)) { $csv .= ",\"\""; } else { if (rsvp_require_only_passcode_to_register()) { $csv .= ",\"" . sprintf($customLinkBase, urlencode(stripslashes($a->passcode))) . "\""; } else { if (rsvp_require_passcode()) { $csv .= ",\"" . sprintf($customLinkBase, urlencode(stripslashes($a->firstName)), urlencode(stripslashes($a->lastName)), urlencode(stripslashes($a->passcode))) . "\""; } else { $csv .= ",\"" . sprintf($customLinkBase, urlencode(stripslashes($a->firstName)), urlencode(stripslashes($a->lastName))) . "\""; } } } $csv .= "\r\n"; } if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) { // IE Bug in download name workaround ini_set('zlib.output_compression', 'Off'); } header('Content-Description: RSVP Export'); header("Content-Type: application/vnd.ms-excel", true); header('Content-Disposition: attachment; filename="rsvpEntries.csv"'); echo $csv; exit; }