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