| 1 |
<?php |
| 2 |
$rsvp_form_action = htmlspecialchars(rsvp_getCurrentPageURL()); |
| 3 |
function rsvp_handle_output ($intialText, $rsvpText) { |
| 4 |
return str_replace(RSVP_FRONTEND_TEXT_CHECK, $rsvpText, $intialText); |
| 5 |
} |
| 6 |
|
| 7 |
function rsvp_frontend_handler($text) { |
| 8 |
global $wpdb; |
| 9 |
$passcodeOptionEnabled = (get_option(OPTION_RSVP_PASSCODE) == "Y") ? true : false; |
| 10 |
//QUIT if the replacement string doesn't exist |
| 11 |
if (!strstr($text,RSVP_FRONTEND_TEXT_CHECK)) return $text; |
| 12 |
|
| 13 |
// See if we should allow people to RSVP, etc... |
| 14 |
$openDate = get_option(OPTION_OPENDATE); |
| 15 |
$closeDate = get_option(OPTION_DEADLINE); |
| 16 |
if((strtotime($openDate) !== false) && (strtotime($openDate) > time())) { |
| 17 |
return rsvp_handle_output($text, sprintf(__(RSVP_START_PARA."I am sorry but the ability to RSVP for our wedding won't open till <strong>%s</strong>".RSVP_END_PARA, 'rsvp-plugin'), date("m/d/Y", strtotime($openDate)))); |
| 18 |
} |
| 19 |
|
| 20 |
if((strtotime($closeDate) !== false) && (strtotime($closeDate) < time())) { |
| 21 |
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')); |
| 22 |
} |
| 23 |
|
| 24 |
if(isset($_POST['rsvpStep'])) { |
| 25 |
$output = ""; |
| 26 |
switch(strtolower($_POST['rsvpStep'])) { |
| 27 |
case("handlersvp") : |
| 28 |
$output = rsvp_handlersvp($output, $text); |
| 29 |
if(!empty($output)) |
| 30 |
return $output; |
| 31 |
break; |
| 32 |
case("editattendee") : |
| 33 |
$output = rsvp_editAttendee($output, $text); |
| 34 |
if(!empty($output)) |
| 35 |
return $output; |
| 36 |
break; |
| 37 |
case("foundattendee") : |
| 38 |
$output = rsvp_foundAttendee($output, $text); |
| 39 |
if(!empty($output)) |
| 40 |
return $output; |
| 41 |
break; |
| 42 |
case("find") : |
| 43 |
$output = rsvp_find($output, $text); |
| 44 |
if(!empty($output)) |
| 45 |
return $output; |
| 46 |
break; |
| 47 |
case("newsearch"): |
| 48 |
default: |
| 49 |
return rsvp_handle_output($text, rsvp_frontend_greeting()); |
| 50 |
break; |
| 51 |
} |
| 52 |
} else { |
| 53 |
return rsvp_handle_output($text, rsvp_frontend_greeting()); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
function rsvp_handleAdditionalQuestions($attendeeID, $formName) { |
| 58 |
global $wpdb; |
| 59 |
|
| 60 |
$wpdb->query($wpdb->prepare("DELETE FROM ".ATTENDEE_ANSWERS." WHERE attendeeID = %d ", $attendeeID)); |
| 61 |
|
| 62 |
$qRs = $wpdb->get_results("SELECT q.id, questionType FROM ".QUESTIONS_TABLE." q |
| 63 |
INNER JOIN ".QUESTION_TYPE_TABLE." qt ON qt.id = q.questionTypeID |
| 64 |
ORDER BY q.sortOrder"); |
| 65 |
if(count($qRs) > 0) { |
| 66 |
foreach($qRs as $q) { |
| 67 |
if(isset($_POST[$formName.$q->id]) && !empty($_POST[$formName.$q->id])) { |
| 68 |
if($q->questionType == QT_MULTI) { |
| 69 |
$selectedAnswers = ""; |
| 70 |
$aRs = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id)); |
| 71 |
if(count($aRs) > 0) { |
| 72 |
foreach($aRs as $a) { |
| 73 |
if(in_array($a->id, $_POST[$formName.$q->id])) { |
| 74 |
$selectedAnswers .= ((strlen($selectedAnswers) == "0") ? "" : ",").stripslashes($a->answer); |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
if(!empty($selectedAnswers)) { |
| 80 |
$wpdb->insert(ATTENDEE_ANSWERS, array("attendeeID" => $attendeeID, |
| 81 |
"answer" => stripslashes($selectedAnswers), |
| 82 |
"questionID" => $q->id), |
| 83 |
array('%d', '%s', '%d')); |
| 84 |
rsvp_printQueryDebugInfo(); |
| 85 |
} |
| 86 |
} else if (($q->questionType == QT_DROP) || ($q->questionType == QT_RADIO)) { |
| 87 |
$aRs = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id)); |
| 88 |
if(count($aRs) > 0) { |
| 89 |
foreach($aRs as $a) { |
| 90 |
if($a->id == $_POST[$formName.$q->id]) { |
| 91 |
$wpdb->insert(ATTENDEE_ANSWERS, array("attendeeID" => $attendeeID, |
| 92 |
"answer" => stripslashes($a->answer), |
| 93 |
"questionID" => $q->id), |
| 94 |
array('%d', '%s', '%d')); |
| 95 |
rsvp_printQueryDebugInfo(); |
| 96 |
break; |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
} else { |
| 101 |
$wpdb->insert(ATTENDEE_ANSWERS, array("attendeeID" => $attendeeID, |
| 102 |
"answer" => $_POST[$formName.$q->id], |
| 103 |
"questionID" => $q->id), |
| 104 |
array('%d', '%s', '%d')); |
| 105 |
rsvp_printQueryDebugInfo(); |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
function rsvp_frontend_prompt_to_edit($attendee) { |
| 113 |
global $rsvp_form_action; |
| 114 |
$prompt = RSVP_START_CONTAINER; |
| 115 |
$prompt .= sprintf(__(RSVP_START_PARA."Hi %s it looks like you have already RSVP'd. Would you like to edit your reservation?".RSVP_END_PARA, 'rsvp-plugin'), |
| 116 |
htmlspecialchars(stripslashes($attendee->firstName." ".$attendee->lastName))); |
| 117 |
$prompt .= "<form method=\"post\" action=\"$rsvp_form_action\">\r\n |
| 118 |
<input type=\"hidden\" name=\"attendeeID\" value=\"".$attendee->id."\" /> |
| 119 |
<input type=\"hidden\" name=\"rsvpStep\" id=\"rsvpStep\" value=\"editattendee\" /> |
| 120 |
<input type=\"submit\" value=\"Yes\" onclick=\"document.getElementById('rsvpStep').value='editattendee';\" /> |
| 121 |
<input type=\"submit\" value=\"No\" onclick=\"document.getElementById('rsvpStep').value='newsearch';\" /> |
| 122 |
</form>\r\n"; |
| 123 |
$prompt .= RSVP_END_CONTAINER; |
| 124 |
return $prompt; |
| 125 |
} |
| 126 |
|
| 127 |
function rsvp_frontend_main_form($attendeeID) { |
| 128 |
global $wpdb, $rsvp_form_action; |
| 129 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal, personalGreeting |
| 130 |
FROM ".ATTENDEES_TABLE." |
| 131 |
WHERE id = %d", $attendeeID)); |
| 132 |
$sql = "SELECT id FROM ".ATTENDEES_TABLE." |
| 133 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 134 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 135 |
AND additionalAttendee = 'Y'"; |
| 136 |
$newRsvps = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 137 |
$yesText = __("Yes", 'rsvp-plugin'); |
| 138 |
$noText = __("No", 'rsvp-plugin'); |
| 139 |
|
| 140 |
$form = "<form id=\"rsvpForm\" name=\"rsvpForm\" method=\"post\" action=\"$rsvp_form_action\">\r\n"; |
| 141 |
$form .= " <input type=\"hidden\" name=\"attendeeID\" value=\"".$attendeeID."\" />\r\n"; |
| 142 |
$form .= " <input type=\"hidden\" name=\"rsvpStep\" value=\"handleRsvp\" />\r\n"; |
| 143 |
$yesVerbiage = ((trim(get_option(OPTION_YES_VERBIAGE)) != "") ? get_option(OPTION_YES_VERBIAGE) : |
| 144 |
__("Yes, of course I will be there! Who doesn't like family, friends, weddings, and a good time?", 'rsvp-plugin')); |
| 145 |
$noVerbiage = ((trim(get_option(OPTION_NO_VERBIAGE)) != "") ? get_option(OPTION_NO_VERBIAGE) : |
| 146 |
__("Um, unfortunately, there is a Star Trek marathon on that day that I just cannot miss.", 'rsvp-plugin')); |
| 147 |
$kidsVerbiage = ((trim(get_option(OPTION_KIDS_MEAL_VERBIAGE)) != "") ? get_option(OPTION_KIDS_MEAL_VERBIAGE) : |
| 148 |
__("We have the option of getting cheese pizza for the kids (and only kids). Do you want pizza instead of \"adult food?\"", 'rsvp-plugin')); |
| 149 |
$veggieVerbiage = ((trim(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)) != "") ? get_option(OPTION_VEGGIE_MEAL_VERBIAGE) : |
| 150 |
__("We also have the option of getting individual vegetarian meals instead of the fish or meat. Would you like a vegetarian dinner?", 'rsvp-plugin')); |
| 151 |
$noteVerbiage = ((trim(get_option(OPTION_NOTE_VERBIAGE)) != "") ? get_option(OPTION_NOTE_VERBIAGE) : |
| 152 |
__("If you have any <strong style=\"color:red;\">food allergies</strong>, 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')); |
| 153 |
$form .= RSVP_START_PARA; |
| 154 |
if(trim(get_option(OPTION_RSVP_QUESTION)) != "") { |
| 155 |
$form .= trim(get_option(OPTION_RSVP_QUESTION)); |
| 156 |
} else { |
| 157 |
$form .= __("So, how about it?", 'rsvp-plugin'); |
| 158 |
} |
| 159 |
|
| 160 |
$form .= RSVP_END_PARA. |
| 161 |
rsvp_BeginningFormField("", ""). |
| 162 |
"<input type=\"radio\" name=\"mainRsvp\" value=\"Y\" id=\"mainRsvpY\" ".(($attendee->rsvpStatus == "No") ? "" : "checked=\"checked\"")." /> <label for=\"mainRsvpY\">".$yesVerbiage."</label>". |
| 163 |
RSVP_END_FORM_FIELD. |
| 164 |
rsvp_BeginningFormField("", ""). |
| 165 |
"<input type=\"radio\" name=\"mainRsvp\" value=\"N\" id=\"mainRsvpN\" ".(($attendee->rsvpStatus == "No") ? "checked=\"checked\"" : "")." /> ". |
| 166 |
"<label for=\"mainRsvpN\">".$noVerbiage."</label>". |
| 167 |
RSVP_END_FORM_FIELD; |
| 168 |
if(!empty($attendee->personalGreeting)) { |
| 169 |
$form .= rsvp_BeginningFormField("rsvpCustomGreeting", "").nl2br(stripslashes($attendee->personalGreeting)).RSVP_END_FORM_FIELD; |
| 170 |
} |
| 171 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 172 |
$form .= rsvp_BeginningFormField("", "rsvpBorderTop"). |
| 173 |
RSVP_START_PARA.$kidsVerbiage.RSVP_END_PARA. |
| 174 |
"<input type=\"radio\" name=\"mainKidsMeal\" value=\"Y\" id=\"mainKidsMealY\" ". |
| 175 |
(($attendee->kidsMeal == "Y") ? "checked=\"checked\"" : "")." /> <label for=\"mainKidsMealY\">$yesText</label> ". |
| 176 |
"<input type=\"radio\" name=\"mainKidsMeal\" value=\"N\" id=\"mainKidsMealN\" ".(($attendee->kidsMeal == "Y") ? "" : "checked=\"checked\"")." /> <label for=\"mainKidsMealN\">$noText</label>". |
| 177 |
RSVP_END_FORM_FIELD; |
| 178 |
} |
| 179 |
|
| 180 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 181 |
$form .= rsvp_BeginningFormField("", "rsvpBorderTop"). |
| 182 |
RSVP_START_PARA.$veggieVerbiage.RSVP_END_PARA. |
| 183 |
"<input type=\"radio\" name=\"mainVeggieMeal\" value=\"Y\" id=\"mainVeggieMealY\" ". |
| 184 |
(($attendee->veggieMeal == "Y") ? "checked=\"checked\"" : "")."/> <label for=\"mainVeggieMealY\">$yesText</label> ". |
| 185 |
"<input type=\"radio\" name=\"mainVeggieMeal\" value=\"N\" id=\"mainVeggieMealN\" ". |
| 186 |
(($attendee->veggieMeal == "Y") ? "" : "checked=\"checked\"")." /> <label for=\"mainVeggieMealN\">$noText</label>". |
| 187 |
RSVP_END_FORM_FIELD; |
| 188 |
} |
| 189 |
|
| 190 |
$form .= rsvp_buildAdditionalQuestions($attendeeID, "main"); |
| 191 |
|
| 192 |
if(get_option(RSVP_OPTION_HIDE_NOTE) != "Y") { |
| 193 |
$form .= RSVP_START_PARA.$noteVerbiage.RSVP_END_PARA. |
| 194 |
rsvp_BeginningFormField("", ""). |
| 195 |
"<textarea name=\"rsvp_note\" id=\"rsvp_note\" rows=\"7\" cols=\"50\">".$attendee->note."</textarea>".RSVP_END_FORM_FIELD; |
| 196 |
|
| 197 |
} |
| 198 |
$sql = "SELECT id, firstName, lastName FROM ".ATTENDEES_TABLE." |
| 199 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 200 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 201 |
AND rsvpStatus <> 'NoResponse'"; |
| 202 |
$rsvpd = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 203 |
if(count($rsvpd) > 0) { |
| 204 |
$form .= "<div class=\"rsvpAdditionalAttendee\">\r\n"; |
| 205 |
$form .= RSVP_START_PARA.__("The following people associated with you have already registered:", 'rsvp-plugin')." "; |
| 206 |
foreach($rsvpd as $r) { |
| 207 |
$form .= "<br />".htmlspecialchars($r->firstName." ".$r->lastName); |
| 208 |
} |
| 209 |
$form .= RSVP_END_PARA; |
| 210 |
$form .= "</div>"; |
| 211 |
} |
| 212 |
|
| 213 |
$sql = "SELECT id, firstName, lastName, personalGreeting FROM ".ATTENDEES_TABLE." |
| 214 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 215 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 216 |
AND rsvpStatus = 'NoResponse'"; |
| 217 |
|
| 218 |
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 219 |
if(count($associations) > 0) { |
| 220 |
$form .= "<h3>".__("The following people are associated with you. At this time you can RSVP for them as well.", 'rsvp-plugin')."</h3>"; |
| 221 |
foreach($associations as $a) { |
| 222 |
$form .= "<div class=\"rsvpAdditionalAttendee\">\r\n". |
| 223 |
RSVP_START_PARA."<label for=\"rsvpFor".$a->id."\">". |
| 224 |
sprintf(__("RSVP for %s ?",'rsvp-plugin'), htmlspecialchars($a->firstName." ".$a->lastName))."</label> ". |
| 225 |
"<input type=\"checkbox\" name=\"rsvpFor".$a->id."\" id=\"rsvpFor".$a->id."\" value=\"Y\" />".RSVP_END_PARA; |
| 226 |
|
| 227 |
$form .= rsvp_BeginningFormField("", "").sprintf(__(" Will %s be attending?", 'rsvp-plugin'), htmlspecialchars($a->firstName)). |
| 228 |
"<input type=\"radio\" name=\"attending".$a->id."\" value=\"Y\" id=\"attending".$a->id."Y\" checked=\"checked\" /> ". |
| 229 |
"<label for=\"attending".$a->id."Y\">$yesText</label> |
| 230 |
<input type=\"radio\" name=\"attending".$a->id."\" value=\"N\" id=\"attending".$a->id."N\" /> ". |
| 231 |
"<label for=\"attending".$a->id."N\">$noText</label>". |
| 232 |
RSVP_END_FORM_FIELD; |
| 233 |
|
| 234 |
if(!empty($a->personalGreeting)) { |
| 235 |
$form .= RSVP_START_PARA.nl2br($a->personalGreeting).RSVP_END_PARA; |
| 236 |
} |
| 237 |
|
| 238 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 239 |
$form .= rsvp_BeginningFormField("", ""). |
| 240 |
sprintf(__("Does %s need a kids meal", 'rsvp-plugin'), htmlspecialchars($a->firstName))."? ". |
| 241 |
"<input type=\"radio\" name=\"attending".$a->id."KidsMeal\" value=\"Y\" id=\"attending".$a->id."KidsMealY\" /> ". |
| 242 |
"<label for=\"attending".$a->id."KidsMealY\">$yesText</label> |
| 243 |
<input type=\"radio\" name=\"attending".$a->id."KidsMeal\" value=\"N\" id=\"attending".$a->id."KidsMealN\" checked=\"checked\" /> ". |
| 244 |
"<label for=\"attending".$a->id."KidsMealN\">$noText</label>".RSVP_END_FORM_FIELD; |
| 245 |
} |
| 246 |
|
| 247 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 248 |
$form .= rsvp_BeginningFormField("", ""). |
| 249 |
sprintf(__("Does %s need a vegetarian meal?", 'rsvp-plugin'), htmlspecialchars($a->firstName))." ". |
| 250 |
"<input type=\"radio\" name=\"attending".$a->id."VeggieMeal\" value=\"Y\" id=\"attending".$a->id."VeggieMealY\" /> ". |
| 251 |
"<label for=\"attending".$a->id."VeggieMealY\">$yesText</label> |
| 252 |
<input type=\"radio\" name=\"attending".$a->id."VeggieMeal\" value=\"N\" id=\"attending".$a->id."VeggieMealN\" checked=\"checked\" /> ". |
| 253 |
"<label for=\"attending".$a->id."VeggieMealN\">$noText</label>".RSVP_END_FORM_FIELD; |
| 254 |
} |
| 255 |
|
| 256 |
$form .= rsvp_buildAdditionalQuestions($a->id, $a->id); |
| 257 |
$form .= "</div>\r\n"; |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") { |
| 262 |
$form .= "<h3>".__("Did we slip up and forget to invite someone? If so, please add him or her here:", 'rsvp-plugin')."</h3>\r\n"; |
| 263 |
$form .= "<div id=\"additionalRsvpContainer\">\r\n |
| 264 |
<input type=\"hidden\" name=\"additionalRsvp\" id=\"additionalRsvp\" value=\"".count($newRsvps)."\" /> |
| 265 |
<div style=\"text-align:right\"><img ". |
| 266 |
"src=\"".get_option("siteurl")."/wp-content/plugins/rsvp/plus.png\" width=\"24\" height=\"24\" border=\"0\" id=\"addRsvp\" /></div>". |
| 267 |
"</div>"; |
| 268 |
} |
| 269 |
|
| 270 |
$form .= RSVP_START_PARA."<input type=\"submit\" value=\"RSVP\" />".RSVP_END_PARA; |
| 271 |
if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") { |
| 272 |
// TODO: Need to move this into the main JS file but not sure how to do that with the options and the custom questions. |
| 273 |
// - Moving the options would be fairly easy. Just set two JS variables in here and then go off of that. |
| 274 |
// - No clue on custom questions.... |
| 275 |
$form .= "<script type=\"text/javascript\" language=\"javascript\">\r\n |
| 276 |
function handleAddRsvpClick() { |
| 277 |
var numAdditional = jQuery(\"#additionalRsvp\").val(); |
| 278 |
numAdditional++; |
| 279 |
if(numAdditional > 3) { |
| 280 |
alert('".__("You have already added 3 additional rsvp\'s you can add no more.", 'rsvp-plugin')."'); |
| 281 |
} else { |
| 282 |
jQuery(\"#additionalRsvpContainer\").append(\"<div class=\\\"rsvpAdditionalAttendee\\\">\" + \r\n |
| 283 |
\"<div class=\\\"rsvpFormField\\\">\" + \r\n |
| 284 |
\" <label for=\\\"newAttending\" + numAdditional + \"FirstName\\\">".__("Person's first name", 'rsvp-plugin')." </label>\" + \r\n |
| 285 |
\" <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"FirstName\\\" id=\\\"newAttending\" + numAdditional + \"FirstName\\\" />\" + \r\n |
| 286 |
\"</div>\" + \r\n |
| 287 |
\"<div class=\\\"rsvpFormField\\\">\" + \r\n |
| 288 |
\" <label for=\\\"newAttending\" + numAdditional + \"LastName\\\">".__("Person's last name", 'rsvp-plugin')."</label>\" + \r\n |
| 289 |
\" <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"LastName\\\" id=\\\"newAttending\" + numAdditional + \"LastName\\\" />\" + \r\n |
| 290 |
\"</div>\" + \r\n |
| 291 |
\"<div class=\\\"rsvpFormField\\\">\" + \r\n |
| 292 |
\"Will this person be attending? \" + \r\n |
| 293 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"Y\\\" checked=\\\"checked\\\" /> \" + |
| 294 |
\"<label for=\\\"newAttending\" + numAdditional + \"Y\\\">$yesText</label> \" + |
| 295 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"N\\\"> <label for=\\\"newAttending\" + numAdditional + \"N\\\">$noText</label>\" + |
| 296 |
\"</div>\" + \r\n"; |
| 297 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 298 |
$form .= "\"<div class=\\\"rsvpFormField\\\">\" + |
| 299 |
\"".__("Does this person need a kids meal?", 'rsvp-plugin')." \" + |
| 300 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealY\\\" /> \" + |
| 301 |
\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealY\\\">$yesText</label> \" + |
| 302 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealN\\\" checked=\\\"checked\\\" /> \" + |
| 303 |
\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealN\\\">$noText</label>\" + |
| 304 |
\"</div>\" + \r\n"; |
| 305 |
} |
| 306 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 307 |
$form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n |
| 308 |
\"".__("Does this person need a vegetarian meal?", 'rsvp-plugin')." \" + |
| 309 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\" /> \" + |
| 310 |
\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\">$yesText</label> \" + |
| 311 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\" checked=\\\"checked\\\" /> \" + |
| 312 |
\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\">$noText</label>\" + |
| 313 |
\"</div>\" + "; |
| 314 |
} |
| 315 |
$tmpVar = str_replace("\r\n", "", str_replace("|", "\"", addSlashes(rsvp_buildAdditionalQuestions(0, "| + numAdditional + |")))); |
| 316 |
|
| 317 |
$form .= "\"".$tmpVar."\" + |
| 318 |
\"</div>\"); |
| 319 |
jQuery(\"#additionalRsvp\").val(numAdditional); |
| 320 |
} |
| 321 |
} |
| 322 |
</script>\r\n"; |
| 323 |
} |
| 324 |
$form .= "</form>\r\n"; |
| 325 |
|
| 326 |
return $form; |
| 327 |
} |
| 328 |
|
| 329 |
function rsvp_revtrievePreviousAnswer($attendeeID, $questionID) { |
| 330 |
global $wpdb; |
| 331 |
$answers = ""; |
| 332 |
if(($attendeeID > 0) && ($questionID > 0)) { |
| 333 |
$rs = $wpdb->get_results($wpdb->prepare("SELECT answer FROM ".ATTENDEE_ANSWERS." WHERE questionID = %d AND attendeeID = %d", $questionID, $attendeeID)); |
| 334 |
if(count($rs) > 0) { |
| 335 |
$answers = stripslashes($rs[0]->answer); |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
return $answers; |
| 340 |
} |
| 341 |
|
| 342 |
function rsvp_buildAdditionalQuestions($attendeeID, $prefix) { |
| 343 |
global $wpdb; |
| 344 |
$output = ""; |
| 345 |
|
| 346 |
$sql = "SELECT q.id, q.question, questionType FROM ".QUESTIONS_TABLE." q |
| 347 |
INNER JOIN ".QUESTION_TYPE_TABLE." qt ON qt.id = q.questionTypeID |
| 348 |
WHERE q.permissionLevel = 'public' |
| 349 |
OR (q.permissionLevel = 'private' AND q.id IN (SELECT questionID FROM ".QUESTION_ATTENDEES_TABLE." WHERE attendeeID = $attendeeID)) |
| 350 |
ORDER BY q.sortOrder "; |
| 351 |
$questions = $wpdb->get_results($sql); |
| 352 |
if(count($questions) > 0) { |
| 353 |
foreach($questions as $q) { |
| 354 |
$oldAnswer = rsvp_revtrievePreviousAnswer($attendeeID, $q->id); |
| 355 |
|
| 356 |
$output .= rsvp_BeginningFormField("", "").RSVP_START_PARA.stripslashes($q->question).RSVP_END_PARA; |
| 357 |
|
| 358 |
if($q->questionType == QT_MULTI) { |
| 359 |
$oldAnswers = explode(",", $oldAnswer); |
| 360 |
|
| 361 |
$answers = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id)); |
| 362 |
if(count($answers) > 0) { |
| 363 |
$i = 0; |
| 364 |
foreach($answers as $a) { |
| 365 |
$output .= rsvp_BeginningFormField("", "rsvpCheckboxCustomQ")."<input type=\"checkbox\" name=\"".$prefix."question".$q->id."[]\" id=\"".$prefix."question".$q->id.$a->id."\" value=\"".$a->id."\" " |
| 366 |
.((in_array(stripslashes($a->answer), $oldAnswers)) ? " checked=\"checked\"" : "")." />". |
| 367 |
"<label for=\"".$prefix."question".$q->id.$a->id."\">".stripslashes($a->answer)."</label>\r\n".RSVP_END_FORM_FIELD; |
| 368 |
$i++; |
| 369 |
} |
| 370 |
$output .= "<div class=\"rsvpClear\"> </div>\r\n"; |
| 371 |
} |
| 372 |
} else if ($q->questionType == QT_DROP) { |
| 373 |
$oldAnswers = explode(",", $oldAnswer); |
| 374 |
|
| 375 |
$output .= "<select name=\"".$prefix."question".$q->id."\" size=\"1\">\r\n". |
| 376 |
"<option value=\"\">--</option>\r\n"; |
| 377 |
$answers = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id)); |
| 378 |
if(count($answers) > 0) { |
| 379 |
foreach($answers as $a) { |
| 380 |
$output .= "<option value=\"".$a->id."\" ".((in_array(stripslashes($a->answer), $oldAnswers)) ? " selected=\"selected\"" : "").">".stripslashes($a->answer)."</option>\r\n"; |
| 381 |
} |
| 382 |
} |
| 383 |
$output .= "</select>\r\n"; |
| 384 |
} else if ($q->questionType == QT_LONG) { |
| 385 |
$output .= "<textarea name=\"".$prefix."question".$q->id."\" rows=\"5\" cols=\"35\">".htmlspecialchars($oldAnswer)."</textarea>"; |
| 386 |
} else if ($q->questionType == QT_RADIO) { |
| 387 |
$oldAnswers = explode(",", $oldAnswer); |
| 388 |
$answers = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $q->id)); |
| 389 |
if(count($answers) > 0) { |
| 390 |
$i = 0; |
| 391 |
$output .= RSVP_START_PARA; |
| 392 |
foreach($answers as $a) { |
| 393 |
$output .= "<input type=\"radio\" name=\"".$prefix."question".$q->id."\" id=\"".$prefix."question".$q->id.$a->id."\" value=\"".$a->id."\" " |
| 394 |
.((in_array(stripslashes($a->answer), $oldAnswers)) ? " checked=\"checked\"" : "")." /> ". |
| 395 |
"<label for=\"".$prefix."question".$q->id.$a->id."\">".stripslashes($a->answer)."</label>\r\n"; |
| 396 |
$i++; |
| 397 |
} |
| 398 |
$output .= RSVP_END_PARA; |
| 399 |
} |
| 400 |
} else { |
| 401 |
// normal text input |
| 402 |
$output .= "<input type=\"text\" name=\"".$prefix."question".$q->id."\" value=\"".htmlspecialchars($oldAnswer)."\" size=\"25\" />"; |
| 403 |
} |
| 404 |
|
| 405 |
$output .= RSVP_END_FORM_FIELD; |
| 406 |
} |
| 407 |
} |
| 408 |
|
| 409 |
return $output; |
| 410 |
} |
| 411 |
|
| 412 |
function rsvp_find(&$output, &$text) { |
| 413 |
global $wpdb, $rsvp_form_action; |
| 414 |
$passcodeOptionEnabled = (get_option(OPTION_RSVP_PASSCODE) == "Y") ? true : false; |
| 415 |
|
| 416 |
$_SESSION['rsvpFirstName'] = $_POST['firstName']; |
| 417 |
$_SESSION['rsvpLastName'] = $_POST['lastName']; |
| 418 |
$passcode = ""; |
| 419 |
if(isset($_POST['passcode'])) { |
| 420 |
$passcode = $_POST['passcode']; |
| 421 |
$_SESSION['rsvpPasscode'] = $_POST['passcode']; |
| 422 |
} |
| 423 |
|
| 424 |
$firstName = $_POST['firstName']; |
| 425 |
$lastName = $_POST['lastName']; |
| 426 |
|
| 427 |
if((strlen($_POST['firstName']) <= 1) || (strlen($_POST['lastName']) <= 1)) { |
| 428 |
$output = "<p class=\"rsvpParagraph\" style=\"color:red\">".__("A first and last name must be specified", 'rsvp-plugin')."</p>\r\n"; |
| 429 |
$output .= rsvp_frontend_greeting(); |
| 430 |
|
| 431 |
return rsvp_handle_output($text, $output); |
| 432 |
} |
| 433 |
|
| 434 |
// Try to find the user. |
| 435 |
if($passcodeOptionEnabled) { |
| 436 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 437 |
FROM ".ATTENDEES_TABLE." |
| 438 |
WHERE firstName = %s AND lastName = %s AND passcode = %s", $firstName, $lastName, $passcode)); |
| 439 |
} else { |
| 440 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 441 |
FROM ".ATTENDEES_TABLE." |
| 442 |
WHERE firstName = %s AND lastName = %s", $firstName, $lastName)); |
| 443 |
} |
| 444 |
|
| 445 |
if($attendee != null) { |
| 446 |
// hey we found something, we should move on and print out any associated users and let them rsvp |
| 447 |
$output = "<div>\r\n"; |
| 448 |
if(strtolower($attendee->rsvpStatus) == "noresponse") { |
| 449 |
$output .= RSVP_START_PARA."Hi ".htmlspecialchars(stripslashes($attendee->firstName." ".$attendee->lastName))."!".RSVP_END_PARA; |
| 450 |
|
| 451 |
if(trim(get_option(OPTION_WELCOME_TEXT)) != "") { |
| 452 |
$output .= RSVP_START_PARA.trim(get_option(OPTION_WELCOME_TEXT)).RSVP_END_PARA; |
| 453 |
} else { |
| 454 |
$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; |
| 455 |
} |
| 456 |
|
| 457 |
$output .= rsvp_frontend_main_form($attendee->id); |
| 458 |
} else { |
| 459 |
$output .= rsvp_frontend_prompt_to_edit($attendee); |
| 460 |
} |
| 461 |
return rsvp_handle_output($text, $output."</div>\r\n"); |
| 462 |
} |
| 463 |
|
| 464 |
// We did not find anyone let's try and do a rough search |
| 465 |
$attendees = null; |
| 466 |
if(!$passcodeOptionEnabled) { |
| 467 |
for($i = 3; $i >= 1; $i--) { |
| 468 |
$truncFirstName = rsvp_chomp_name($firstName, $i); |
| 469 |
$attendees = $wpdb->get_results("SELECT id, firstName, lastName, rsvpStatus FROM ".ATTENDEES_TABLE." |
| 470 |
WHERE lastName = '".mysql_real_escape_string($lastName)."' AND firstName LIKE '".mysql_real_escape_string($truncFirstName)."%'"); |
| 471 |
if(count($attendees) > 0) { |
| 472 |
$output = RSVP_START_PARA."<strong>".__("We could not find an exact match but could any of the below entries be you?", 'rsvp-plugin')."</strong>".RSVP_END_PARA; |
| 473 |
foreach($attendees as $a) { |
| 474 |
$output .= "<form method=\"post\" action=\"$rsvp_form_action\">\r\n |
| 475 |
<input type=\"hidden\" name=\"rsvpStep\" value=\"foundattendee\" />\r\n |
| 476 |
<input type=\"hidden\" name=\"attendeeID\" value=\"".$a->id."\" />\r\n |
| 477 |
<p class=\"rsvpParagraph\" style=\"text-align:left;\">\r\n |
| 478 |
".htmlspecialchars($a->firstName." ".$a->lastName)." |
| 479 |
<input type=\"submit\" value=\"RSVP\" />\r\n |
| 480 |
</p>\r\n</form>\r\n"; |
| 481 |
} |
| 482 |
return rsvp_handle_output($text, $output); |
| 483 |
} else { |
| 484 |
$i = strlen($truncFirstName); |
| 485 |
} |
| 486 |
} |
| 487 |
} |
| 488 |
$notFoundText = sprintf(__(RSVP_START_PARA.'<strong>We were unable to find anyone with a name of %1$s %2$s</strong>'.RSVP_END_PARA, 'rsvp-plugin'), htmlspecialchars($firstName), htmlspecialchars($lastName)); |
| 489 |
$notFoundText .= rsvp_frontend_greeting(); |
| 490 |
return rsvp_handle_output($text, $notFoundText); |
| 491 |
} |
| 492 |
|
| 493 |
function rsvp_handlersvp(&$output, &$text) { |
| 494 |
global $wpdb; |
| 495 |
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) { |
| 496 |
// update their information and what not.... |
| 497 |
if(strToUpper($_POST['mainRsvp']) == "Y") { |
| 498 |
$rsvpStatus = "Yes"; |
| 499 |
} else { |
| 500 |
$rsvpStatus = "No"; |
| 501 |
} |
| 502 |
$attendeeID = $_POST['attendeeID']; |
| 503 |
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"), |
| 504 |
"rsvpStatus" => $rsvpStatus, |
| 505 |
"note" => $_POST['rsvp_note'], |
| 506 |
"kidsMeal" => ((isset($_POST['mainKidsMeal']) && (strToUpper($_POST['mainKidsMeal']) == "Y")) ? "Y" : "N"), |
| 507 |
"veggieMeal" => ((isset($_POST['mainVeggieMeal']) && (strToUpper($_POST['mainVeggieMeal']) == "Y")) ? "Y" : "N")), |
| 508 |
array("id" => $attendeeID), |
| 509 |
array("%s", "%s", "%s", "%s", "%s"), |
| 510 |
array("%d")); |
| 511 |
rsvp_printQueryDebugInfo(); |
| 512 |
rsvp_handleAdditionalQuestions($attendeeID, "mainquestion"); |
| 513 |
|
| 514 |
$sql = "SELECT id FROM ".ATTENDEES_TABLE." |
| 515 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 516 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 517 |
AND rsvpStatus = 'NoResponse'"; |
| 518 |
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 519 |
foreach($associations as $a) { |
| 520 |
if($_POST['rsvpFor'.$a->id] == "Y") { |
| 521 |
if($_POST['attending'.$a->id] == "Y") { |
| 522 |
$rsvpStatus = "Yes"; |
| 523 |
} else { |
| 524 |
$rsvpStatus = "No"; |
| 525 |
} |
| 526 |
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"), |
| 527 |
"rsvpStatus" => $rsvpStatus, |
| 528 |
"kidsMeal" => ((strToUpper((isset($_POST['attending'.$a->id.'KidsMeal']) ? $_POST['attending'.$a->id.'KidsMeal'] : "N")) == "Y") ? "Y" : "N"), |
| 529 |
"veggieMeal" => ((strToUpper((isset($_POST['attending'.$a->id.'VeggieMeal']) ? $_POST['attending'.$a->id.'VeggieMeal'] : "N")) == "Y") ? "Y" : "N")), |
| 530 |
array("id" => $a->id), |
| 531 |
array("%s", "%s", "%s", "%s"), |
| 532 |
array("%d")); |
| 533 |
rsvp_printQueryDebugInfo(); |
| 534 |
rsvp_handleAdditionalQuestions($a->id, $a->id."question"); |
| 535 |
} |
| 536 |
} |
| 537 |
|
| 538 |
if(get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") { |
| 539 |
if(is_numeric($_POST['additionalRsvp']) && ($_POST['additionalRsvp'] > 0)) { |
| 540 |
for($i = 1; $i <= $_POST['additionalRsvp']; $i++) { |
| 541 |
if(($i <= 3) && |
| 542 |
!empty($_POST['newAttending'.$i.'FirstName']) && |
| 543 |
!empty($_POST['newAttending'.$i.'LastName'])) { |
| 544 |
$wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($_POST['newAttending'.$i.'FirstName']), |
| 545 |
"lastName" => trim($_POST['newAttending'.$i.'LastName']), |
| 546 |
"rsvpDate" => date("Y-m-d"), |
| 547 |
"rsvpStatus" => (($_POST['newAttending'.$i] == "Y") ? "Yes" : "No"), |
| 548 |
"kidsMeal" => (isset($_POST['newAttending'.$i.'KidsMeal']) ? $_POST['newAttending'.$i.'KidsMeal'] : "N"), |
| 549 |
"veggieMeal" => (isset($_POST['newAttending'.$i.'VeggieMeal']) ? $_POST['newAttending'.$i.'VeggieMeal'] : "N"), |
| 550 |
"additionalAttendee" => "Y"), |
| 551 |
array('%s', '%s', '%s', '%s', '%s', '%s')); |
| 552 |
rsvp_printQueryDebugInfo(); |
| 553 |
$newAid = $wpdb->insert_id; |
| 554 |
rsvp_handleAdditionalQuestions($newAid, $i.'question'); |
| 555 |
// Add associations for this new user |
| 556 |
$wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID" => $newAid, |
| 557 |
"associatedAttendeeID" => $attendeeID), |
| 558 |
array("%d", "%d")); |
| 559 |
rsvp_printQueryDebugInfo(); |
| 560 |
$wpdb->query($wpdb->prepare("INSERT INTO ".ASSOCIATED_ATTENDEES_TABLE."(attendeeID, associatedAttendeeID) |
| 561 |
SELECT ".$newAid.", associatedAttendeeID |
| 562 |
FROM ".ASSOCIATED_ATTENDEES_TABLE." |
| 563 |
WHERE attendeeID = ".$attendeeID)); |
| 564 |
rsvp_printQueryDebugInfo(); |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
} |
| 569 |
|
| 570 |
if((get_option(OPTION_NOTIFY_ON_RSVP) == "Y") && (get_option(OPTION_NOTIFY_EMAIL) != "")) { |
| 571 |
$sql = "SELECT firstName, lastName, rsvpStatus FROM ".ATTENDEES_TABLE." WHERE id= ".$attendeeID; |
| 572 |
$attendee = $wpdb->get_results($sql); |
| 573 |
if(count($attendee) > 0) { |
| 574 |
$body = "Hello, \r\n\r\n"; |
| 575 |
|
| 576 |
$body .= stripslashes($attendee[0]->firstName)." ".stripslashes($attendee[0]->lastName). |
| 577 |
" has submitted their RSVP and has RSVP'd with '".$attendee[0]->rsvpStatus."'."; |
| 578 |
|
| 579 |
wp_mail(get_option(OPTION_NOTIFY_EMAIL), "New RSVP Submission", $body); |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
return rsvp_handle_output($text, frontend_rsvp_thankyou()); |
| 584 |
} else { |
| 585 |
return rsvp_handle_output($text, rsvp_frontend_greeting()); |
| 586 |
} |
| 587 |
} |
| 588 |
|
| 589 |
function rsvp_editAttendee(&$output, &$text) { |
| 590 |
global $wpdb; |
| 591 |
|
| 592 |
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) { |
| 593 |
// Try to find the user. |
| 594 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 595 |
FROM ".ATTENDEES_TABLE." |
| 596 |
WHERE id = %d", $_POST['attendeeID'])); |
| 597 |
if($attendee != null) { |
| 598 |
$output .= RSVP_START_CONTAINER; |
| 599 |
$output .= RSVP_START_PARA.__("Welcome back", 'rsvp-plugin')." ".htmlspecialchars($attendee->firstName." ".$attendee->lastName)."!".RSVP_END_PARA; |
| 600 |
$output .= rsvp_frontend_main_form($attendee->id); |
| 601 |
return rsvp_handle_output($text, $output.RSVP_END_CONTAINER); |
| 602 |
} |
| 603 |
} |
| 604 |
} |
| 605 |
|
| 606 |
function rsvp_foundAttendee(&$output, &$text) { |
| 607 |
global $wpdb; |
| 608 |
|
| 609 |
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) { |
| 610 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 611 |
FROM ".ATTENDEES_TABLE." |
| 612 |
WHERE id = %d", $_POST['attendeeID'])); |
| 613 |
if($attendee != null) { |
| 614 |
$output = RSVP_START_CONTAINER; |
| 615 |
if(strtolower($attendee->rsvpStatus) == "noresponse") { |
| 616 |
$output .= RSVP_START_PARA.__("Hi", 'rsvp-plugin')." ".htmlspecialchars(stripslashes($attendee->firstName." ".$attendee->lastName))."!".RSVP_END_PARA; |
| 617 |
|
| 618 |
if(trim(get_option(OPTION_WELCOME_TEXT)) != "") { |
| 619 |
$output .= RSVP_START_PARA.trim(get_option(OPTION_WELCOME_TEXT)).RSVP_END_PARA; |
| 620 |
} else { |
| 621 |
$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; |
| 622 |
} |
| 623 |
|
| 624 |
$output .= rsvp_frontend_main_form($attendee->id); |
| 625 |
} else { |
| 626 |
$output .= rsvp_frontend_prompt_to_edit($attendee); |
| 627 |
} |
| 628 |
return rsvp_handle_output($text, $output.RSVP_END_CONTAINER); |
| 629 |
} |
| 630 |
|
| 631 |
return rsvp_handle_output($text, rsvp_frontend_greeting()); |
| 632 |
} else { |
| 633 |
return rsvp_handle_output($text, rsvp_frontend_greeting()); |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
function frontend_rsvp_thankyou() { |
| 640 |
$customTy = get_option(OPTION_THANKYOU); |
| 641 |
if(!empty($customTy)) { |
| 642 |
return nl2br($customTy); |
| 643 |
} else { |
| 644 |
return RSVP_START_CONTAINER.RSVP_START_PARA.__("Thank you for RSVPing", 'rsvp-plugin').RSVP_END_PARA.RSVP_END_CONTAINER; |
| 645 |
} |
| 646 |
} |
| 647 |
|
| 648 |
function rsvp_chomp_name($name, $maxLength) { |
| 649 |
for($i = $maxLength; $maxLength >= 1; $i--) { |
| 650 |
if(strlen($name) >= $i) { |
| 651 |
return substr($name, 0, $i); |
| 652 |
} |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
function rsvp_BeginningFormField($id, $additionalClasses) { |
| 657 |
return "<div ".(!empty($id) ? "id=\"$id\"" : "")." class=\"rsvpFormField ".(!empty($additionalClasses) ? $additionalClasses : "")."\">"; |
| 658 |
} |
| 659 |
|
| 660 |
function rsvp_frontend_greeting() { |
| 661 |
global $rsvp_form_action; |
| 662 |
$customGreeting = get_option(OPTION_GREETING); |
| 663 |
$output = RSVP_START_PARA.__("Please enter your first and last name to RSVP.", 'rsvp-plugin').RSVP_END_PARA; |
| 664 |
$firstName = ""; |
| 665 |
$lastName = ""; |
| 666 |
$passcode = ""; |
| 667 |
if(isset($_SESSION['rsvpFirstName'])) { |
| 668 |
$firstName = $_SESSION['rsvpFirstName']; |
| 669 |
} |
| 670 |
if(isset($_SESSION['rsvpLastName'])) { |
| 671 |
$lastName = $_SESSION['rsvpLastName']; |
| 672 |
} |
| 673 |
if(isset($_SESSION['rsvpPasscode'])) { |
| 674 |
$passcode = $_SESSION['rsvpPasscode']; |
| 675 |
} |
| 676 |
if(!empty($customGreeting)) { |
| 677 |
$output = RSVP_START_PARA.nl2br($customGreeting).RSVP_END_PARA; |
| 678 |
} |
| 679 |
$output .= RSVP_START_CONTAINER; |
| 680 |
$output .= "<form name=\"rsvp\" method=\"post\" id=\"rsvp\" action=\"$rsvp_form_action\">\r\n"; |
| 681 |
$output .= " <input type=\"hidden\" name=\"rsvpStep\" value=\"find\" />"; |
| 682 |
$output .= RSVP_START_PARA."<label for=\"firstName\">First Name:</label> |
| 683 |
<input type=\"text\" name=\"firstName\" id=\"firstName\" size=\"30\" value=\"".htmlspecialchars($firstName)."\" class=\"required\" />".RSVP_END_PARA; |
| 684 |
$output .= RSVP_START_PARA."<label for=\"lastName\">Last Name:</label> |
| 685 |
<input type=\"text\" name=\"lastName\" id=\"lastName\" size=\"30\" value=\"".htmlspecialchars($lastName)."\" class=\"required\" />".RSVP_END_PARA; |
| 686 |
if(get_option(OPTION_RSVP_PASSCODE) == "Y") { |
| 687 |
$output .= RSVP_START_PARA."<label for=\"passcode\">Passcode:</label> |
| 688 |
<input type=\"text\" name=\"passcode\" id=\"passcode\" size=\"30\" value=\"".htmlspecialchars($passcode)."\" class=\"required\" />".RSVP_END_PARA; |
| 689 |
} |
| 690 |
$output .= RSVP_START_PARA."<input type=\"submit\" value=\"".__("Complete your RSVP!", 'rsvp-plugin')."\" />".RSVP_END_PARA; |
| 691 |
$output .= "</form>\r\n"; |
| 692 |
$output .= RSVP_END_CONTAINER; |
| 693 |
return $output; |
| 694 |
} |
| 695 |
?> |
| 696 |
|