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("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_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) { $prompt = RSVP_START_CONTAINER; $prompt .= RSVP_START_PARA."Hi ".htmlentities(stripslashes($attendee->firstName." ".$attendee->lastName))." it looks like you have already RSVP'd. Would you like to edit your reservation?".RSVP_END_PARA; $prompt .= "
\r\n id."\" />
\r\n"; $prompt .= RSVP_END_CONTAINER; return $prompt; } function rsvp_frontend_main_form($attendeeID) { global $wpdb; $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)); $form = "
\r\n"; $form .= " \r\n"; $form .= " \r\n"; $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 .= RSVP_START_PARA; if(trim(get_option(OPTION_RSVP_QUESTION)) != "") { $form .= trim(get_option(OPTION_RSVP_QUESTION)); } else { $form .= __("So, how about it?", 'rsvp-plugin'); } $form .= RSVP_END_PARA. rsvp_BeginningFormField("", ""). "rsvpStatus == "No") ? "" : "checked=\"checked\"")." /> ". RSVP_END_FORM_FIELD. rsvp_BeginningFormField("", ""). "rsvpStatus == "No") ? "checked=\"checked\"" : "")." /> ". RSVP_END_FORM_FIELD; if(!empty($attendee->personalGreeting)) { $form .= rsvp_BeginningFormField("rsvpCustomGreeting", "").nl2br(stripslashes($attendee->personalGreeting)).RSVP_END_FORM_FIELD; } if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { $form .= rsvp_BeginningFormField("", "rsvpBorderTop"). RSVP_START_PARA.$kidsVerbiage.RSVP_END_PARA. "kidsMeal == "Y") ? "checked=\"checked\"" : "")." /> kidsMeal == "Y") ? "" : "checked=\"checked\"")." /> ". RSVP_END_FORM_FIELD; } if(get_option(OPTION_HIDE_VEGGIE) != "Y") { $form .= rsvp_BeginningFormField("", "rsvpBorderTop"). RSVP_START_PARA.$veggieVerbiage.RSVP_END_PARA. "veggieMeal == "Y") ? "checked=\"checked\"" : "")."/> veggieMeal == "Y") ? "" : "checked=\"checked\"")." /> ". RSVP_END_FORM_FIELD; } $form .= rsvp_buildAdditionalQuestions($attendeeID, "main"); $form .= RSVP_START_PARA.$noteVerbiage.RSVP_END_PARA. rsvp_BeginningFormField("", ""). "".RSVP_END_FORM_FIELD; $sql = "SELECT id, firstName, lastName 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'"; $rsvpd = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); if(count($rsvpd) > 0) { $form .= "
\r\n"; $form .= RSVP_START_PARA.__("The following people associated with you have already registered:", 'rsvp-plugin')." "; foreach($rsvpd as $r) { $form .= "
".htmlentities($r->firstName." ".$r->lastName); } $form .= RSVP_END_PARA; $form .= "
"; } $sql = "SELECT id, firstName, lastName, personalGreeting 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)); if(count($associations) > 0) { $form .= "

".__("The following people are associated with you. At this time you can RSVP for them as well.", 'rsvp-plugin')."

"; foreach($associations as $a) { $form .= "
\r\n". RSVP_START_PARA." id."\" id=\"rsvpFor".$a->id."\" value=\"Y\" />".RSVP_END_PARA; $form .= rsvp_BeginningFormField("", "")." Will ".htmlentities($a->firstName)." be attending? id."\" value=\"Y\" id=\"attending".$a->id."Y\" checked=\"checked\" /> id."\" value=\"N\" id=\"attending".$a->id."N\" /> ". RSVP_END_FORM_FIELD; if(!empty($a->personalGreeting)) { $form .= RSVP_START_PARA.nl2br($a->personalGreeting).RSVP_END_PARA; } if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { $form .= rsvp_BeginningFormField("", ""). "Does ".htmlentities($a->firstName)." need a kids meal?  id."KidsMeal\" value=\"Y\" id=\"attending".$a->id."KidsMealY\" /> id."KidsMeal\" value=\"N\" id=\"attending".$a->id."KidsMealN\" checked=\"checked\" /> ".RSVP_END_FORM_FIELD; } if(get_option(OPTION_HIDE_VEGGIE) != "Y") { $form .= rsvp_BeginningFormField("", "")."Does ".htmlentities($a->firstName)." need a vegetarian meal?  id."VeggieMeal\" value=\"Y\" id=\"attending".$a->id."VeggieMealY\" /> id."VeggieMeal\" value=\"N\" id=\"attending".$a->id."VeggieMealN\" checked=\"checked\" /> ".RSVP_END_FORM_FIELD; } $form .= rsvp_buildAdditionalQuestions($a->id, $a->id); $form .= "
\r\n"; } } if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") { $form .= "

".__("Did we slip up and forget to invite someone? If so, please add him or her here:", 'rsvp-plugin')."

\r\n"; $form .= "
\r\n
". "
"; } $form .= RSVP_START_PARA."".RSVP_END_PARA; if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") { // TODO: Need to move this into the main JS file but not sure how to do that with the options and the custom questions. // - Moving the options would be fairly easy. Just set two JS variables in here and then go off of that. // - No clue on custom questions.... $form .= "\r\n"; } $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; $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 .= "
 
\r\n"; } } else if ($q->questionType == QT_DROP) { $oldAnswers = explode(",", $oldAnswer); $output .= "\r\n"; } else if ($q->questionType == QT_LONG) { $output .= ""; } else if ($q->questionType == QT_RADIO) { $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; $output .= RSVP_START_PARA; foreach($answers as $a) { $output .= "id."\" id=\"".$prefix."question".$q->id.$a->id."\" value=\"".$a->id."\" " .((in_array(stripslashes($a->answer), $oldAnswers)) ? " checked=\"checked\"" : "")." /> ". "\r\n"; $i++; } $output .= RSVP_END_PARA; } } else { // normal text input $output .= "id."\" value=\"".htmlentities($oldAnswer)."\" size=\"25\" />"; } $output .= RSVP_END_FORM_FIELD; } } return $output; } function rsvp_find(&$output, &$text) { global $wpdb; $passcodeOptionEnabled = (get_option(OPTION_RSVP_PASSCODE) == "Y") ? true : false; $_SESSION['rsvpFirstName'] = $_POST['firstName']; $_SESSION['rsvpLastName'] = $_POST['lastName']; $passcode = ""; if(isset($_POST['passcode'])) { $passcode = $_POST['passcode']; $_SESSION['rsvpPasscode'] = $_POST['passcode']; } $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; if((strlen($_POST['firstName']) <= 1) || (strlen($_POST['lastName']) <= 1)) { $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 ".htmlentities(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 \r\n id."\" />\r\n

\r\n ".htmlentities($a->firstName." ".$a->lastName)." \r\n

\r\n
\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'), htmlentities($firstName), htmlentities($lastName)); $notFoundText .= rsvp_frontend_greeting(); return rsvp_handle_output($text, $notFoundText); } 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 = ".$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')." ".htmlentities($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')." ".htmlentities(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_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() { $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; $output .= "
\r\n"; $output .= " "; $output .= RSVP_START_PARA." ".RSVP_END_PARA; $output .= RSVP_START_PARA." ".RSVP_END_PARA; if(get_option(OPTION_RSVP_PASSCODE) == "Y") { $output .= RSVP_START_PARA." ".RSVP_END_PARA; } $output .= RSVP_START_PARA."".RSVP_END_PARA; $output .= "
\r\n"; $output .= RSVP_END_CONTAINER; return $output; } ?>