".$rsvpText;
return str_replace(RSVP_FRONTEND_TEXT_CHECK, $rsvpText, $intialText);
}
function rsvp_frontend_handler($text) {
global $wpdb;
$passcodeOptionEnabled = (rsvp_require_passcode()) ? true : false;
//QUIT if the replacement string doesn't exist
if (!strstr($text,RSVP_FRONTEND_TEXT_CHECK)) return $text;
// See if we should allow people to RSVP, etc...
$openDate = get_option(OPTION_OPENDATE);
$closeDate = get_option(OPTION_DEADLINE);
if((strtotime($openDate) !== false) && (strtotime($openDate) > time())) {
return rsvp_handle_output($text, sprintf(__(RSVP_START_PARA."I am sorry but the ability to RSVP for our wedding won't open till %s".RSVP_END_PARA, 'rsvp-plugin'), date("m/d/Y", strtotime($openDate))));
}
if((strtotime($closeDate) !== false) && (strtotime($closeDate) < time())) {
return rsvp_handle_output($text, __(RSVP_START_PARA."The deadline to RSVP for this wedding has passed, please contact the bride and groom to see if there is still a seat for you.".RSVP_END_PARA, 'rsvp-plugin'));
}
if(isset($_POST['rsvpStep'])) {
$output = "";
switch(strtolower($_POST['rsvpStep'])) {
case("newattendee"):
return rsvp_handlenewattendee($output, $text);
break;
case("addattendee"):
return rsvp_handleNewRsvp($output, $text);
break;
case("handlersvp") :
$output = rsvp_handlersvp($output, $text);
if(!empty($output))
return $output;
break;
case("editattendee") :
$output = rsvp_editAttendee($output, $text);
if(!empty($output))
return $output;
break;
case("foundattendee") :
$output = rsvp_foundAttendee($output, $text);
if(!empty($output))
return $output;
break;
case("find") :
$output = rsvp_find($output, $text);
if(!empty($output))
return $output;
break;
case("newsearch"):
default:
return rsvp_handle_output($text, rsvp_frontend_greeting());
break;
}
} else {
return rsvp_handle_output($text, rsvp_frontend_greeting());
}
}
function rsvp_handlenewattendee($output, $text) {
$output = RSVP_START_CONTAINER;
$output .= rsvp_frontend_main_form(0, "addAttendee");
$output .= RSVP_END_CONTAINER;
return rsvp_handle_output($text, $output);
}
function rsvp_handleAdditionalQuestions($attendeeID, $formName) {
global $wpdb;
$wpdb->query($wpdb->prepare("DELETE FROM ".ATTENDEE_ANSWERS." WHERE attendeeID = %d ", $attendeeID));
$qRs = $wpdb->get_results("SELECT q.id, questionType FROM ".QUESTIONS_TABLE." q
INNER JOIN ".QUESTION_TYPE_TABLE." qt ON qt.id = q.questionTypeID
ORDER BY q.sortOrder");
if(count($qRs) > 0) {
foreach($qRs as $q) {
if(isset($_POST[$formName.$q->id]) && !empty($_POST[$formName.$q->id])) {
if($q->questionType == QT_MULTI) {
$selectedAnswers = "";
$aRs = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id));
if(count($aRs) > 0) {
foreach($aRs as $a) {
if(in_array($a->id, $_POST[$formName.$q->id])) {
$selectedAnswers .= ((strlen($selectedAnswers) == "0") ? "" : ",").stripslashes($a->answer);
}
}
}
if(!empty($selectedAnswers)) {
$wpdb->insert(ATTENDEE_ANSWERS, array("attendeeID" => $attendeeID,
"answer" => stripslashes($selectedAnswers),
"questionID" => $q->id),
array('%d', '%s', '%d'));
rsvp_printQueryDebugInfo();
}
} else if (($q->questionType == QT_DROP) || ($q->questionType == QT_RADIO)) {
$aRs = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id));
if(count($aRs) > 0) {
foreach($aRs as $a) {
if($a->id == $_POST[$formName.$q->id]) {
$wpdb->insert(ATTENDEE_ANSWERS, array("attendeeID" => $attendeeID,
"answer" => stripslashes($a->answer),
"questionID" => $q->id),
array('%d', '%s', '%d'));
rsvp_printQueryDebugInfo();
break;
}
}
}
} else {
$wpdb->insert(ATTENDEE_ANSWERS, array("attendeeID" => $attendeeID,
"answer" => $_POST[$formName.$q->id],
"questionID" => $q->id),
array('%d', '%s', '%d'));
rsvp_printQueryDebugInfo();
}
}
}
}
}
function rsvp_frontend_prompt_to_edit($attendee) {
global $rsvp_form_action;
$prompt = RSVP_START_CONTAINER;
$editGreeting = __("Hi %s it looks like you have already RSVP'd. Would you like to edit your reservation?", 'rsvp-plugin');
$prompt .= sprintf(RSVP_START_PARA.$editGreeting.RSVP_END_PARA,
htmlspecialchars(stripslashes($attendee->firstName." ".$attendee->lastName)));
$prompt .= "
\r\n";
$prompt .= RSVP_END_CONTAINER;
return $prompt;
}
function rsvp_frontend_main_form($attendeeID, $rsvpStep = "handleRsvp") {
global $wpdb, $rsvp_form_action, $rsvp_saved_form_vars;
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal, personalGreeting
FROM ".ATTENDEES_TABLE."
WHERE id = %d", $attendeeID));
$sql = "SELECT id FROM ".ATTENDEES_TABLE."
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d)
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d))
AND additionalAttendee = 'Y'";
$newRsvps = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
$yesText = __("Yes", 'rsvp-plugin');
$noText = __("No", 'rsvp-plugin');
$yesVerbiage = ((trim(get_option(OPTION_YES_VERBIAGE)) != "") ? get_option(OPTION_YES_VERBIAGE) :
__("Yes, of course I will be there! Who doesn't like family, friends, weddings, and a good time?", 'rsvp-plugin'));
$noVerbiage = ((trim(get_option(OPTION_NO_VERBIAGE)) != "") ? get_option(OPTION_NO_VERBIAGE) :
__("Um, unfortunately, there is a Star Trek marathon on that day that I just cannot miss.", 'rsvp-plugin'));
$kidsVerbiage = ((trim(get_option(OPTION_KIDS_MEAL_VERBIAGE)) != "") ? get_option(OPTION_KIDS_MEAL_VERBIAGE) :
__("We have the option of getting cheese pizza for the kids (and only kids). Do you want pizza instead of \"adult food?\"", 'rsvp-plugin'));
$veggieVerbiage = ((trim(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)) != "") ? get_option(OPTION_VEGGIE_MEAL_VERBIAGE) :
__("We also have the option of getting individual vegetarian meals instead of the fish or meat. Would you like a vegetarian dinner?", 'rsvp-plugin'));
$noteVerbiage = ((trim(get_option(OPTION_NOTE_VERBIAGE)) != "") ? get_option(OPTION_NOTE_VERBIAGE) :
__("If you have any food allergies, please indicate what they are in the "notes" section below. Or, if you just want to send us a note, please feel free. If you have any questions, please send us an email.", 'rsvp-plugin'));
$form = "\r\n";
return $form;
}
function rsvp_revtrievePreviousAnswer($attendeeID, $questionID) {
global $wpdb;
$answers = "";
if(($attendeeID > 0) && ($questionID > 0)) {
$rs = $wpdb->get_results($wpdb->prepare("SELECT answer FROM ".ATTENDEE_ANSWERS." WHERE questionID = %d AND attendeeID = %d", $questionID, $attendeeID));
if(count($rs) > 0) {
$answers = stripslashes($rs[0]->answer);
}
}
return $answers;
}
function rsvp_buildAdditionalQuestions($attendeeID, $prefix) {
global $wpdb, $rsvp_saved_form_vars;
$output = "";
$sql = "SELECT q.id, q.question, questionType FROM ".QUESTIONS_TABLE." q
INNER JOIN ".QUESTION_TYPE_TABLE." qt ON qt.id = q.questionTypeID
WHERE q.permissionLevel = 'public'
OR (q.permissionLevel = 'private' AND q.id IN (SELECT questionID FROM ".QUESTION_ATTENDEES_TABLE." WHERE attendeeID = $attendeeID))
ORDER BY q.sortOrder ";
$questions = $wpdb->get_results($sql);
if(count($questions) > 0) {
foreach($questions as $q) {
$oldAnswer = rsvp_revtrievePreviousAnswer($attendeeID, $q->id);
$output .= rsvp_BeginningFormField("", "").RSVP_START_PARA.stripslashes($q->question).RSVP_END_PARA;
if($q->questionType == QT_MULTI) {
$oldAnswers = explode(",", $oldAnswer);
$answers = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id));
if(count($answers) > 0) {
$i = 0;
foreach($answers as $a) {
$output .= rsvp_BeginningFormField("", "rsvpCheckboxCustomQ")."id."[]\" id=\"".$prefix."question".$q->id.$a->id."\" value=\"".$a->id."\" "
.((in_array(stripslashes($a->answer), $oldAnswers)) ? " checked=\"checked\"" : "")." />".
"\r\n".RSVP_END_FORM_FIELD;
$i++;
}
$output .= "
".__("A first and last name must be specified", 'rsvp-plugin')."
\r\n";
$output .= rsvp_frontend_greeting();
return rsvp_handle_output($text, $output);
}
// Try to find the user.
if($passcodeOptionEnabled) {
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus
FROM ".ATTENDEES_TABLE."
WHERE firstName = %s AND lastName = %s AND passcode = %s", $firstName, $lastName, $passcode));
} else {
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus
FROM ".ATTENDEES_TABLE."
WHERE firstName = %s AND lastName = %s", $firstName, $lastName));
}
if($attendee != null) {
// hey we found something, we should move on and print out any associated users and let them rsvp
$output = "
\r\n";
if(strtolower($attendee->rsvpStatus) == "noresponse") {
$output .= RSVP_START_PARA."Hi ".htmlspecialchars(stripslashes($attendee->firstName." ".$attendee->lastName))."!".RSVP_END_PARA;
if(trim(get_option(OPTION_WELCOME_TEXT)) != "") {
$output .= RSVP_START_PARA.trim(get_option(OPTION_WELCOME_TEXT)).RSVP_END_PARA;
} else {
$output .= RSVP_START_PARA.__("There are a few more questions we need to ask you if you could please fill them out below to finish up the RSVP process.", 'rsvp-plugin').RSVP_END_PARA;
}
$output .= rsvp_frontend_main_form($attendee->id);
} else {
$output .= rsvp_frontend_prompt_to_edit($attendee);
}
return rsvp_handle_output($text, $output."
\r\n");
}
// We did not find anyone let's try and do a rough search
$attendees = null;
if(!$passcodeOptionEnabled) {
for($i = 3; $i >= 1; $i--) {
$truncFirstName = rsvp_chomp_name($firstName, $i);
$attendees = $wpdb->get_results("SELECT id, firstName, lastName, rsvpStatus FROM ".ATTENDEES_TABLE."
WHERE lastName = '".mysql_real_escape_string($lastName)."' AND firstName LIKE '".mysql_real_escape_string($truncFirstName)."%'");
if(count($attendees) > 0) {
$output = RSVP_START_PARA."".__("We could not find an exact match but could any of the below entries be you?", 'rsvp-plugin')."".RSVP_END_PARA;
foreach($attendees as $a) {
$output .= "\r\n";
}
return rsvp_handle_output($text, $output);
} else {
$i = strlen($truncFirstName);
}
}
}
$notFoundText = sprintf(__(RSVP_START_PARA.'We were unable to find anyone with a name of %1$s %2$s'.RSVP_END_PARA, 'rsvp-plugin'), htmlspecialchars($firstName), htmlspecialchars($lastName));
$notFoundText .= rsvp_frontend_greeting();
return rsvp_handle_output($text, $notFoundText);
}
function rsvp_handleNewRsvp(&$output, &$text) {
global $wpdb, $rsvp_saved_form_vars;
foreach($_POST as $key=>$val) {
$rsvp_saved_form_vars[$key] = $val;
}
if(empty($_POST['attendeeFirstName']) || empty($_POST['attendeeLastName'])) {
return rsvp_handlenewattendee($output, $text);
}
$rsvpPassword = "";
$rsvpStatus = "No";
if(strToUpper($_POST['mainRsvp']) == "Y") {
$rsvpStatus = "Yes";
}
$kidsMeal = ((isset($_POST['mainKidsMeal']) && (strToUpper($_POST['mainKidsMeal']) == "Y")) ? "Y" : "N");
$veggieMeal = ((isset($_POST['mainVeggieMeal']) && (strToUpper($_POST['mainVeggieMeal']) == "Y")) ? "Y" : "N");
$wpdb->insert(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"),
"firstName" => $_POST['attendeeFirstName'],
"lastName" => $_POST['attendeeLastName'],
"rsvpStatus" => $rsvpStatus,
"note" => $_POST['rsvp_note'],
"kidsMeal" => $kidsMeal,
"veggieMeal" => $veggieMeal),
array("%s", "%s", "%s", "%s", "%s", "%s", "%s"));
rsvp_printQueryDebugInfo();
$attendeeID = $wpdb->insert_id;
if(rsvp_require_passcode()) {
$rsvpPassword = trim(rsvp_generate_passcode());
$wpdb->update(ATTENDEES_TABLE,
array("passcode" => $rsvpPassword),
array("id"=>$attendeeID),
array("%s"),
array("%d"));
}
rsvp_handleAdditionalQuestions($attendeeID, "mainquestion");
$sql = "SELECT id FROM ".ATTENDEES_TABLE."
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d)
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d))
AND rsvpStatus = 'NoResponse'";
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
foreach($associations as $a) {
if($_POST['rsvpFor'.$a->id] == "Y") {
if($_POST['attending'.$a->id] == "Y") {
$rsvpStatus = "Yes";
} else {
$rsvpStatus = "No";
}
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"),
"rsvpStatus" => $rsvpStatus,
"kidsMeal" => ((strToUpper((isset($_POST['attending'.$a->id.'KidsMeal']) ? $_POST['attending'.$a->id.'KidsMeal'] : "N")) == "Y") ? "Y" : "N"),
"veggieMeal" => ((strToUpper((isset($_POST['attending'.$a->id.'VeggieMeal']) ? $_POST['attending'.$a->id.'VeggieMeal'] : "N")) == "Y") ? "Y" : "N")),
array("id" => $a->id),
array("%s", "%s", "%s", "%s"),
array("%d"));
rsvp_printQueryDebugInfo();
rsvp_handleAdditionalQuestions($a->id, $a->id."question");
}
}
if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
if(is_numeric($_POST['additionalRsvp']) && ($_POST['additionalRsvp'] > 0)) {
for($i = 1; $i <= $_POST['additionalRsvp']; $i++) {
if(($i <= 3) &&
!empty($_POST['newAttending'.$i.'FirstName']) &&
!empty($_POST['newAttending'.$i.'LastName'])) {
$wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($_POST['newAttending'.$i.'FirstName']),
"lastName" => trim($_POST['newAttending'.$i.'LastName']),
"rsvpDate" => date("Y-m-d"),
"rsvpStatus" => (($_POST['newAttending'.$i] == "Y") ? "Yes" : "No"),
"kidsMeal" => (isset($_POST['newAttending'.$i.'KidsMeal']) ? $_POST['newAttending'.$i.'KidsMeal'] : "N"),
"veggieMeal" => (isset($_POST['newAttending'.$i.'VeggieMeal']) ? $_POST['newAttending'.$i.'VeggieMeal'] : "N"),
"additionalAttendee" => "Y"),
array('%s', '%s', '%s', '%s', '%s', '%s'));
rsvp_printQueryDebugInfo();
$newAid = $wpdb->insert_id;
rsvp_handleAdditionalQuestions($newAid, $i.'question');
// Add associations for this new user
$wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID" => $newAid,
"associatedAttendeeID" => $attendeeID),
array("%d", "%d"));
rsvp_printQueryDebugInfo();
$wpdb->query($wpdb->prepare("INSERT INTO ".ASSOCIATED_ATTENDEES_TABLE."(attendeeID, associatedAttendeeID)
SELECT ".$newAid.", associatedAttendeeID
FROM ".ASSOCIATED_ATTENDEES_TABLE."
WHERE attendeeID = ".$attendeeID));
rsvp_printQueryDebugInfo();
}
}
}
}
if((get_option(OPTION_NOTIFY_ON_RSVP) == "Y") && (get_option(OPTION_NOTIFY_EMAIL) != "")) {
$sql = "SELECT firstName, lastName, rsvpStatus FROM ".ATTENDEES_TABLE." WHERE id= ".$attendeeID;
$attendee = $wpdb->get_results($sql);
if(count($attendee) > 0) {
$body = "Hello, \r\n\r\n";
$body .= stripslashes($attendee[0]->firstName)." ".stripslashes($attendee[0]->lastName).
" has submitted their RSVP and has RSVP'd with '".$attendee[0]->rsvpStatus."'.";
wp_mail(get_option(OPTION_NOTIFY_EMAIL), "New RSVP Submission", $body);
}
}
return rsvp_handle_output($text, rsvp_frontend_new_atendee_thankyou($rsvpPassword));
}
function rsvp_handlersvp(&$output, &$text) {
global $wpdb;
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) {
// update their information and what not....
if(strToUpper($_POST['mainRsvp']) == "Y") {
$rsvpStatus = "Yes";
} else {
$rsvpStatus = "No";
}
$attendeeID = $_POST['attendeeID'];
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"),
"rsvpStatus" => $rsvpStatus,
"note" => $_POST['rsvp_note'],
"kidsMeal" => ((isset($_POST['mainKidsMeal']) && (strToUpper($_POST['mainKidsMeal']) == "Y")) ? "Y" : "N"),
"veggieMeal" => ((isset($_POST['mainVeggieMeal']) && (strToUpper($_POST['mainVeggieMeal']) == "Y")) ? "Y" : "N")),
array("id" => $attendeeID),
array("%s", "%s", "%s", "%s", "%s"),
array("%d"));
rsvp_printQueryDebugInfo();
rsvp_handleAdditionalQuestions($attendeeID, "mainquestion");
$sql = "SELECT id FROM ".ATTENDEES_TABLE."
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d)
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d))
AND rsvpStatus = 'NoResponse'";
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
foreach($associations as $a) {
if($_POST['rsvpFor'.$a->id] == "Y") {
if($_POST['attending'.$a->id] == "Y") {
$rsvpStatus = "Yes";
} else {
$rsvpStatus = "No";
}
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"),
"rsvpStatus" => $rsvpStatus,
"kidsMeal" => ((strToUpper((isset($_POST['attending'.$a->id.'KidsMeal']) ? $_POST['attending'.$a->id.'KidsMeal'] : "N")) == "Y") ? "Y" : "N"),
"veggieMeal" => ((strToUpper((isset($_POST['attending'.$a->id.'VeggieMeal']) ? $_POST['attending'.$a->id.'VeggieMeal'] : "N")) == "Y") ? "Y" : "N")),
array("id" => $a->id),
array("%s", "%s", "%s", "%s"),
array("%d"));
rsvp_printQueryDebugInfo();
rsvp_handleAdditionalQuestions($a->id, $a->id."question");
}
}
if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
if(is_numeric($_POST['additionalRsvp']) && ($_POST['additionalRsvp'] > 0)) {
for($i = 1; $i <= $_POST['additionalRsvp']; $i++) {
if(($i <= 3) &&
!empty($_POST['newAttending'.$i.'FirstName']) &&
!empty($_POST['newAttending'.$i.'LastName'])) {
$wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($_POST['newAttending'.$i.'FirstName']),
"lastName" => trim($_POST['newAttending'.$i.'LastName']),
"rsvpDate" => date("Y-m-d"),
"rsvpStatus" => (($_POST['newAttending'.$i] == "Y") ? "Yes" : "No"),
"kidsMeal" => (isset($_POST['newAttending'.$i.'KidsMeal']) ? $_POST['newAttending'.$i.'KidsMeal'] : "N"),
"veggieMeal" => (isset($_POST['newAttending'.$i.'VeggieMeal']) ? $_POST['newAttending'.$i.'VeggieMeal'] : "N"),
"additionalAttendee" => "Y"),
array('%s', '%s', '%s', '%s', '%s', '%s'));
rsvp_printQueryDebugInfo();
$newAid = $wpdb->insert_id;
rsvp_handleAdditionalQuestions($newAid, $i.'question');
// Add associations for this new user
$wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID" => $newAid,
"associatedAttendeeID" => $attendeeID),
array("%d", "%d"));
rsvp_printQueryDebugInfo();
$wpdb->query($wpdb->prepare("INSERT INTO ".ASSOCIATED_ATTENDEES_TABLE."(attendeeID, associatedAttendeeID)
SELECT ".$newAid.", associatedAttendeeID
FROM ".ASSOCIATED_ATTENDEES_TABLE."
WHERE attendeeID = %d", $attendeeID));
rsvp_printQueryDebugInfo();
}
}
}
}
if((get_option(OPTION_NOTIFY_ON_RSVP) == "Y") && (get_option(OPTION_NOTIFY_EMAIL) != "")) {
$sql = "SELECT firstName, lastName, rsvpStatus FROM ".ATTENDEES_TABLE." WHERE id= ".$attendeeID;
$attendee = $wpdb->get_results($sql);
if(count($attendee) > 0) {
$body = "Hello, \r\n\r\n";
$body .= stripslashes($attendee[0]->firstName)." ".stripslashes($attendee[0]->lastName).
" has submitted their RSVP and has RSVP'd with '".$attendee[0]->rsvpStatus."'.";
wp_mail(get_option(OPTION_NOTIFY_EMAIL), "New RSVP Submission", $body);
}
}
return rsvp_handle_output($text, frontend_rsvp_thankyou());
} else {
return rsvp_handle_output($text, rsvp_frontend_greeting());
}
}
function rsvp_editAttendee(&$output, &$text) {
global $wpdb;
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) {
// Try to find the user.
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus
FROM ".ATTENDEES_TABLE."
WHERE id = %d", $_POST['attendeeID']));
if($attendee != null) {
$output .= RSVP_START_CONTAINER;
$output .= RSVP_START_PARA.__("Welcome back", 'rsvp-plugin')." ".htmlspecialchars($attendee->firstName." ".$attendee->lastName)."!".RSVP_END_PARA;
$output .= rsvp_frontend_main_form($attendee->id);
return rsvp_handle_output($text, $output.RSVP_END_CONTAINER);
}
}
}
function rsvp_foundAttendee(&$output, &$text) {
global $wpdb;
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) {
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus
FROM ".ATTENDEES_TABLE."
WHERE id = %d", $_POST['attendeeID']));
if($attendee != null) {
$output = RSVP_START_CONTAINER;
if(strtolower($attendee->rsvpStatus) == "noresponse") {
$output .= RSVP_START_PARA.__("Hi", 'rsvp-plugin')." ".htmlspecialchars(stripslashes($attendee->firstName." ".$attendee->lastName))."!".RSVP_END_PARA;
if(trim(get_option(OPTION_WELCOME_TEXT)) != "") {
$output .= RSVP_START_PARA.trim(get_option(OPTION_WELCOME_TEXT)).RSVP_END_PARA;
} else {
$output .= RSVP_START_PARA.__("There are a few more questions we need to ask you if you could please fill them out below to finish up the RSVP process.", 'rsvp-plugin').RSVP_END_PARA;
}
$output .= rsvp_frontend_main_form($attendee->id);
} else {
$output .= rsvp_frontend_prompt_to_edit($attendee);
}
return rsvp_handle_output($text, $output.RSVP_END_CONTAINER);
}
return rsvp_handle_output($text, rsvp_frontend_greeting());
} else {
return rsvp_handle_output($text, rsvp_frontend_greeting());
}
}
function frontend_rsvp_thankyou() {
$customTy = get_option(OPTION_THANKYOU);
if(!empty($customTy)) {
return nl2br($customTy);
} else {
return RSVP_START_CONTAINER.RSVP_START_PARA.__("Thank you for RSVPing", 'rsvp-plugin').RSVP_END_PARA.RSVP_END_CONTAINER;
}
}
function rsvp_frontend_new_atendee_thankyou($password = "") {
/*$customTy = get_option(OPTION_THANKYOU);
if(!empty($customTy)) {
return nl2br($customTy);
} else {*/
$thankYouText = "Thank you for RSVPing. To modify your RSVP just come back ".
"to this page and enter in your first and last name.";
if(!empty($password)) {
$thankYouText .= " You will also need to know your password which is - $password";
}
return RSVP_START_CONTAINER.RSVP_START_PARA.__($thankYouText, 'rsvp-plugin').RSVP_END_PARA.RSVP_END_CONTAINER;
//}
}
function rsvp_chomp_name($name, $maxLength) {
for($i = $maxLength; $maxLength >= 1; $i--) {
if(strlen($name) >= $i) {
return substr($name, 0, $i);
}
}
}
function rsvp_BeginningFormField($id, $additionalClasses) {
return "
";
}
function rsvp_frontend_greeting() {
global $rsvp_form_action;
$customGreeting = get_option(OPTION_GREETING);
$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 .= "\r\n";
$output .= "";
$output .= RSVP_START_PARA.__("Need to modify your registration? Start with the below form.", "rsvp-plugin").RSVP_END_PARA;
}
$output .= "\r\n";
$output .= RSVP_END_CONTAINER;
return $output;
}
?>