| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package rsvp |
| 4 |
* @author MDE Development, LLC |
| 5 |
* @version 1.0.0 |
| 6 |
*/ |
| 7 |
/* |
| 8 |
Plugin Name: RSVP |
| 9 |
Plugin URI: http://wordpress.org/# |
| 10 |
Description: This plugin allows guests to RSVP to an event. It was made |
| 11 |
initially for weddings but could be used for other things. |
| 12 |
Author: MDE Development, LLC |
| 13 |
Version: 0.5.0 |
| 14 |
Author URI: http://mde-dev.com |
| 15 |
License: GPL |
| 16 |
*/ |
| 17 |
# |
| 18 |
# INSTALLATION: see readme.txt |
| 19 |
# |
| 20 |
# USAGE: Once the RSVP plugin has been installed, you can set the custom text |
| 21 |
# via Settings -> RSVP Options in the admin area. |
| 22 |
# |
| 23 |
# To add, edit, delete and see rsvp status there will be a new RSVP admin |
| 24 |
# area just go there. |
| 25 |
# |
| 26 |
# To allow people to rsvp create a new page and add "rsvp_pluginhere" to the text |
| 27 |
|
| 28 |
session_start(); |
| 29 |
define("ATTENDEES_TABLE", $wpdb->prefix."attendees"); |
| 30 |
define("ASSOCIATED_ATTENDEES_TABLE", $wpdb->prefix."associatedAttendees"); |
| 31 |
define("EDIT_SESSION_KEY", "RsvpEditAttendeeID"); |
| 32 |
define("FRONTEND_TEXT_CHECK", "rsvp-pluginhere"); |
| 33 |
define("OPTION_GREETING", "rsvp_custom_greeting"); |
| 34 |
define("OPTION_THANKYOU", "rsvp_custom_thankyou"); |
| 35 |
define("OPTION_DEADLINE", "rsvp_deadline"); |
| 36 |
define("OPTION_OPENDATE", 'rsvp_opendate'); |
| 37 |
define("OPTION_YES_VERBIAGE", "rsvp_yes_verbiage"); |
| 38 |
define("OPTION_NO_VERBIAGE", "rsvp_no_verbiage"); |
| 39 |
define("OPTION_KIDS_MEAL_VERBIAGE", "rsvp_kids_meal_verbiage"); |
| 40 |
define("OPTION_VEGGIE_MEAL_VERBIAGE", "rsvp_veggie_meal_verbiage"); |
| 41 |
define("OPTION_NOTE_VERBIAGE", "rsvp_note_verbiage"); |
| 42 |
define("OPTION_HIDE_VEGGIE", "rsvp_hide_veggie"); |
| 43 |
define("OPTION_HIDE_KIDS_MEAL", "rsvp_hide_kids_meal"); |
| 44 |
|
| 45 |
if(isset($_GET['page']) && (strToLower($_GET['page']) == 'rsvp-admin-export')) { |
| 46 |
add_action('init', 'rsvp_admin_export'); |
| 47 |
} |
| 48 |
/* |
| 49 |
* Description: Database setup for the rsvp plug-in. |
| 50 |
*/ |
| 51 |
function rsvp_database_setup() { |
| 52 |
global $wpdb; |
| 53 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 54 |
|
| 55 |
$table = $wpdb->prefix."attendees"; |
| 56 |
if($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) { |
| 57 |
$sql = "CREATE TABLE ".$table." ( |
| 58 |
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , |
| 59 |
`firstName` VARCHAR( 100 ) NOT NULL , |
| 60 |
`lastName` VARCHAR( 100 ) NOT NULL , |
| 61 |
`rsvpDate` DATE NOT NULL , |
| 62 |
`rsvpStatus` ENUM( 'Yes', 'No', 'NoResponse' ) NOT NULL DEFAULT 'NoResponse', |
| 63 |
`note` TEXT NOT NULL , |
| 64 |
`kidsMeal` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N', |
| 65 |
`additionalAttendee` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N', |
| 66 |
`veggieMeal` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N' |
| 67 |
);"; |
| 68 |
dbDelta($sql); |
| 69 |
} |
| 70 |
$table = $wpdb->prefix."associatedAttendees"; |
| 71 |
if($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) { |
| 72 |
$sql = "CREATE TABLE ".$table." ( |
| 73 |
`attendeeID` INT NOT NULL , |
| 74 |
`associatedAttendeeID` INT NOT NULL |
| 75 |
);"; |
| 76 |
dbDelta($sql); |
| 77 |
$sql = "ALTER TABLE `".$table."` ADD INDEX ( `attendeeID` ) "; |
| 78 |
dbDelta($sql); |
| 79 |
$sql = "ALTER TABLE `".$table."` ADD INDEX ( `associatedAttendeeID` )"; |
| 80 |
dbDelta($sql); |
| 81 |
} |
| 82 |
add_option("rsvp_db_version", "1.0"); |
| 83 |
} |
| 84 |
|
| 85 |
function rsvp_admin_guestlist_options() { |
| 86 |
?> |
| 87 |
<link rel="stylesheet" href="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/jquery-ui-1.7.2.custom/css/ui-lightness/jquery-ui-1.7.2.custom.css" type="text/css" media="all" /> |
| 88 |
<script type="text/javascript" language="javascript" |
| 89 |
src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/jquery-ui-1.7.2.custom/js/jquery-1.3.2.min.js"></script> |
| 90 |
<script type="text/javascript" language="javascript" |
| 91 |
src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/jquery-ui-1.7.2.custom/js/jquery-ui-1.7.2.custom.min.js"></script> |
| 92 |
<script type="text/javascript" language="javascript"> |
| 93 |
$(document).ready(function() { |
| 94 |
$("#rsvp_opendate").datepicker(); |
| 95 |
$("#rsvp_deadline").datepicker(); |
| 96 |
}); |
| 97 |
</script> |
| 98 |
<div class="wrap"> |
| 99 |
<h2>RSVP Guestlist Options</h2> |
| 100 |
<form method="post" action="options.php"> |
| 101 |
<?php wp_nonce_field('update-options'); ?> |
| 102 |
<table class="form-table"> |
| 103 |
<tr valign="top"> |
| 104 |
<th scope="row"><label for="rsvp_opendate">RSVP Open Date:</label></th> |
| 105 |
<td align="left"><input type="text" name="rsvp_opendate" id="rsvp_opendate" value="<?php echo htmlspecialchars(get_option(OPTION_OPENDATE)); ?>" /></td> |
| 106 |
</tr> |
| 107 |
<tr valign="top"> |
| 108 |
<th scope="row"><label for="rsvp_deadline">RSVP Deadline:</label></th> |
| 109 |
<td align="left"><input type="text" name="rsvp_deadline" id="rsvp_deadline" value="<?php echo htmlspecialchars(get_option(OPTION_DEADLINE)); ?>" /></td> |
| 110 |
</tr> |
| 111 |
<tr valign="top"> |
| 112 |
<th scope="row"><label for="rsvp_custom_greeting">Custom Greeting:</label></th> |
| 113 |
<td align="left"><textarea name="rsvp_custom_greeting" id="rsvp_custom_greeting" rows="5" cols="60"><?php echo htmlspecialchars(get_option(OPTION_GREETING)); ?></textarea></td> |
| 114 |
</tr> |
| 115 |
<tr valign="top"> |
| 116 |
<th scope="row"><label for="rsvp_yes_verbiage">RSVP Yes Verbiage:</label></th> |
| 117 |
<td align="left"><input type="text" name="rsvp_yes_verbiage" id="rsvp_yes_verbiage" |
| 118 |
value="<?php echo htmlspecialchars(get_option(OPTION_YES_VERBIAGE)); ?>" size="65" /></td> |
| 119 |
</tr> |
| 120 |
<tr valign="top"> |
| 121 |
<th scope="row"><label for="rsvp_no_verbiage">RSVP No Verbiage:</label></th> |
| 122 |
<td align="left"><input type="text" name="rsvp_no_verbiage" id="rsvp_no_verbiage" |
| 123 |
value="<?php echo htmlspecialchars(get_option(OPTION_NO_VERBIAGE)); ?>" size="65" /></td> |
| 124 |
</tr> |
| 125 |
<tr valign="top"> |
| 126 |
<th scope="row"><label for="rsvp_kids_meal_verbiage">RSVP Kids Meal Verbiage:</label></th> |
| 127 |
<td align="left"><input type="text" name="rsvp_kids_meal_verbiage" id="rsvp_kids_meal_verbiage" |
| 128 |
value="<?php echo htmlspecialchars(get_option(OPTION_KIDS_MEAL_VERBIAGE)); ?>" size="65" /></td> |
| 129 |
</tr> |
| 130 |
<tr valign="top"> |
| 131 |
<th scope="row"><label for="rsvp_hide_kids_meal">Hide Kids Meal Question:</label></th> |
| 132 |
<td align="left"><input type="checkbox" name="rsvp_hide_kids_meal" id="rsvp_hide_kids_meal" |
| 133 |
value="Y" <?php echo ((get_option(OPTION_HIDE_KIDS_MEAL) == "Y") ? " checked=\"checked\"" : ""); ?> /></td> |
| 134 |
</tr> |
| 135 |
<tr valign="top"> |
| 136 |
<th scope="row"><label for="rsvp_veggie_meal_verbiage">RSVP Vegetarian Meal Verbiage:</label></th> |
| 137 |
<td align="left"><input type="text" name="rsvp_veggie_meal_verbiage" id="rsvp_veggie_meal_verbiage" |
| 138 |
value="<?php echo htmlspecialchars(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)); ?>" size="65" /></td> |
| 139 |
</tr> |
| 140 |
<tr valign="top"> |
| 141 |
<th scope="row"><label for="rsvp_hide_veggie">Hide Vegetarian Meal Question:</label></th> |
| 142 |
<td align="left"><input type="checkbox" name="rsvp_hide_veggie" id="rsvp_hide_veggie" |
| 143 |
value="Y" <?php echo ((get_option(OPTION_HIDE_VEGGIE) == "Y") ? " checked=\"checked\"" : ""); ?> /></td> |
| 144 |
</tr> |
| 145 |
<tr valign="top"> |
| 146 |
<th scope="row"><label for="rsvp_note_verbiage">Note Verbiage:</label></th> |
| 147 |
<td align="left"><textarea name="rsvp_note_verbiage" id="rsvp_note_verbiage" rows="3" cols="60"><?php |
| 148 |
echo htmlspecialchars(get_option(OPTION_NOTE_VERBIAGE)); ?></textarea></td> |
| 149 |
</tr> |
| 150 |
<tr valign="top"> |
| 151 |
<th scope="row"><label for="rsvp_custom_thankyou">Custom Thank You:</label></th> |
| 152 |
<td align="left"><textarea name="rsvp_custom_thankyou" id="rsvp_custom_thankyou" rows="5" cols="60"><?php echo htmlspecialchars(get_option(OPTION_THANKYOU)); ?></textarea></td> |
| 153 |
</tr> |
| 154 |
</table> |
| 155 |
<input type="hidden" name="action" value="update" /> |
| 156 |
<p class="submit"> |
| 157 |
<input type="hidden" name="page_options" |
| 158 |
value="rsvp_opendate,rsvp_deadline,rsvp_custom_greeting,rsvp_custom_thankyou,rsvp_no_verbiage,rsvp_yes_verbiage,rsvp_kids_meal_verbiage,rsvp_veggie_meal_verbiage,rsvp_note_verbiage,rsvp_hide_kids_meal,rsvp_hide_veggie" /> |
| 159 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 160 |
</p> |
| 161 |
</form> |
| 162 |
</div> |
| 163 |
<?php |
| 164 |
} |
| 165 |
|
| 166 |
function rsvp_admin_guestlist() { |
| 167 |
global $wpdb; |
| 168 |
if((count($_POST) > 0) && ($_POST['rsvp-bulk-action'] == "delete") && (is_array($_POST['attendee']) && (count($_POST['attendee']) > 0))) { |
| 169 |
foreach($_POST['attendee'] as $attendee) { |
| 170 |
if(is_numeric($attendee) && ($attendee > 0)) { |
| 171 |
$wpdb->query($wpdb->prepare("DELETE FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d OR associatedAttendeeID = %d", |
| 172 |
$attendee, |
| 173 |
$attendee)); |
| 174 |
$wpdb->query($wpdb->prepare("DELETE FROM ".ATTENDEES_TABLE." WHERE id = %d", |
| 175 |
$attendee)); |
| 176 |
} |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
$sql = "SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal FROM ".ATTENDEES_TABLE; |
| 181 |
$orderBy = " lastName, firstName"; |
| 182 |
if(isset($_GET['sort'])) { |
| 183 |
if(strToLower($_GET['sort']) == "rsvpstatus") { |
| 184 |
$orderBy = " rsvpStatus ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy; |
| 185 |
}else if(strToLower($_GET['sort']) == "attendee") { |
| 186 |
$direction = ((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC"); |
| 187 |
$orderBy = " lastName $direction, firstName $direction"; |
| 188 |
} else if(strToLower($_GET['sort']) == "kidsmeal") { |
| 189 |
$orderBy = " kidsMeal ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy; |
| 190 |
} else if(strToLower($_GET['sort']) == "additional") { |
| 191 |
$orderBy = " additionalAttendee ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy; |
| 192 |
} else if(strToLower($_GET['sort']) == "vegetarian") { |
| 193 |
$orderBy = " veggieMeal ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy; |
| 194 |
} |
| 195 |
} |
| 196 |
$sql .= " ORDER BY ".$orderBy; |
| 197 |
$attendees = $wpdb->get_results($sql); |
| 198 |
?> |
| 199 |
<div class="wrap"> |
| 200 |
<div id="icon-edit" class="icon32"><br /></div> |
| 201 |
<h2>List of current attendees</h2> |
| 202 |
<form method="post" id="rsvp-form" enctype="multipart/form-data"> |
| 203 |
<input type="hidden" id="rsvp-bulk-action" name="rsvp-bulk-action" /> |
| 204 |
<div class="tablenav"> |
| 205 |
<div class="alignleft actions"> |
| 206 |
<select id="rsvp-action-top" name="action"> |
| 207 |
<option value="" selected="selected"><?php _e('Bulk Actions', 'rsvp'); ?></option> |
| 208 |
<option value="delete"><?php _e('Delete', 'rsvp'); ?></option> |
| 209 |
</select> |
| 210 |
<input type="submit" value="<?php _e('Apply', 'rsvp'); ?>" name="doaction" id="doaction" class="button-secondary action" onclick="document.getElementById('rsvp-bulk-action').value = document.getElementById('rsvp-action-top').value;" /> |
| 211 |
</div> |
| 212 |
<?php |
| 213 |
$yesResults = $wpdb->get_results("SELECT COUNT(*) AS yesCount FROM ".ATTENDEES_TABLE." WHERE rsvpStatus = 'Yes'"); |
| 214 |
$noResults = $wpdb->get_results("SELECT COUNT(*) AS noCount FROM ".ATTENDEES_TABLE." WHERE rsvpStatus = 'No'"); |
| 215 |
$noResponseResults = $wpdb->get_results("SELECT COUNT(*) AS noResponseCount FROM ".ATTENDEES_TABLE." WHERE rsvpStatus = 'NoResponse'"); |
| 216 |
?> |
| 217 |
<div class="alignright">RSVP Count - |
| 218 |
Yes: <strong><?php echo $yesResults[0]->yesCount; ?></strong> |
| 219 |
No: <strong><?php echo $noResults[0]->noCount; ?></strong> |
| 220 |
No Response: <strong><?php echo $noResponseResults[0]->noResponseCount; ?></strong> |
| 221 |
</div> |
| 222 |
<div class="clear"></div> |
| 223 |
</div> |
| 224 |
<table class="widefat post fixed" cellspacing="0"> |
| 225 |
<thead> |
| 226 |
<tr> |
| 227 |
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> |
| 228 |
<th scope="col" id="attendeeName" class="manage-column column-title" style="">Attendee</a> |
| 229 |
<a href="admin.php?page=rsvp-top-level&sort=attendee&sortDirection=asc"> |
| 230 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/uparrow<?php |
| 231 |
echo ((($_GET['sort'] == "attendee") && ($_GET['sortDirection'] == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 232 |
alt="Sort Ascending Attendee Status" title="Sort Ascending Attendee Status" border="0"></a> |
| 233 |
<a href="admin.php?page=rsvp-top-level&sort=attendee&sortDirection=desc"> |
| 234 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/downarrow<?php |
| 235 |
echo ((($_GET['sort'] == "attendee") && ($_GET['sortDirection'] == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 236 |
alt="Sort Descending Attendee Status" title="Sort Descending Attendee Status" border="0"></a> |
| 237 |
</th> |
| 238 |
<th scope="col" id="rsvpStatus" class="manage-column column-title" style="">RSVP Status |
| 239 |
<a href="admin.php?page=rsvp-top-level&sort=rsvpStatus&sortDirection=asc"> |
| 240 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/uparrow<?php |
| 241 |
echo ((($_GET['sort'] == "rsvpStatus") && ($_GET['sortDirection'] == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 242 |
alt="Sort Ascending RSVP Status" title="Sort Ascending RSVP Status" border="0"></a> |
| 243 |
<a href="admin.php?page=rsvp-top-level&sort=rsvpStatus&sortDirection=desc"> |
| 244 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/downarrow<?php |
| 245 |
echo ((($_GET['sort'] == "rsvpStatus") && ($_GET['sortDirection'] == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 246 |
alt="Sort Descending RSVP Status" title="Sort Descending RSVP Status" border="0"></a> |
| 247 |
</th> |
| 248 |
<?php if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {?> |
| 249 |
<th scope="col" id="kidsMeal" class="manage-column column-title" style="">Kids Meal |
| 250 |
<a href="admin.php?page=rsvp-top-level&sort=kidsMeal&sortDirection=asc"> |
| 251 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/uparrow<?php |
| 252 |
echo ((($_GET['sort'] == "kidsMeal") && ($_GET['sortDirection'] == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 253 |
alt="Sort Ascending Kids Meal Status" title="Sort Ascending Kids Meal Status" border="0"></a> |
| 254 |
<a href="admin.php?page=rsvp-top-level&sort=kidsMeal&sortDirection=desc"> |
| 255 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/downarrow<?php |
| 256 |
echo ((($_GET['sort'] == "kidsMeal") && ($_GET['sortDirection'] == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 257 |
alt="Sort Descending Kids Meal Status" title="Sort Descending Kids Meal Status" border="0"></a> |
| 258 |
</th> |
| 259 |
<?php } ?> |
| 260 |
<th scope="col" id="additionalAttendee" class="manage-column column-title" style="">Additional Attendee |
| 261 |
<a href="admin.php?page=rsvp-top-level&sort=additional&sortDirection=asc"> |
| 262 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/uparrow<?php |
| 263 |
echo ((($_GET['sort'] == "additional") && ($_GET['sortDirection'] == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 264 |
alt="Sort Ascending Additional Attendees Status" title="Sort Ascending Additional Attendees Status" border="0"></a> |
| 265 |
<a href="admin.php?page=rsvp-top-level&sort=additional&sortDirection=desc"> |
| 266 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/downarrow<?php |
| 267 |
echo ((($_GET['sort'] == "additional") && ($_GET['sortDirection'] == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 268 |
alt="Sort Descending Additional Attendees Status" title="Sort Descending Additional Atttendees Status" border="0"></a> |
| 269 |
</th> |
| 270 |
<?php if(get_option(OPTION_HIDE_VEGGIE) != "Y") {?> |
| 271 |
<th scope="col" id="veggieMeal" class="manage-column column-title" style="">Vegetarian |
| 272 |
<a href="admin.php?page=rsvp-top-level&sort=vegetarian&sortDirection=asc"> |
| 273 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/uparrow<?php |
| 274 |
echo ((($_GET['sort'] == "vegetarian") && ($_GET['sortDirection'] == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 275 |
alt="Sort Ascending Vegetarian Status" title="Sort Ascending Vegetarian Status" border="0"></a> |
| 276 |
<a href="admin.php?page=rsvp-top-level&sort=vegetarian&sortDirection=desc"> |
| 277 |
<img src="<?php echo get_option("siteurl"); ?>/wp-content/plugins/rsvp/downarrow<?php |
| 278 |
echo ((($_GET['sort'] == "vegetarian") && ($_GET['sortDirection'] == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9" |
| 279 |
alt="Sort Descending Vegetarian Status" title="Sort Descending Vegetarian Status" border="0"></a> |
| 280 |
</th> |
| 281 |
<?php } ?> |
| 282 |
<th scope="col" id="note" class="manage-column column-title" style="">Note</th> |
| 283 |
<th scope="col" id="associatedAttendees" class="manage-column column-title" style="">Associated Attendees</th> |
| 284 |
</tr> |
| 285 |
</thead> |
| 286 |
</table> |
| 287 |
<div style="overflow: auto;height: 450px;"> |
| 288 |
<table class="widefat post fixed" cellspacing="0"> |
| 289 |
<?php |
| 290 |
$i = 0; |
| 291 |
foreach($attendees as $attendee) { |
| 292 |
?> |
| 293 |
<tr class="<?php echo (($i % 2 == 0) ? "alternate" : ""); ?> author-self"> |
| 294 |
<th scope="row" class="check-column"><input type="checkbox" name="attendee[]" value="<?php echo $attendee->id; ?>" /></th> |
| 295 |
<td> |
| 296 |
<a href="<?php echo get_option("siteurl"); ?>/wp-admin/admin.php?page=rsvp-admin-guest&id=<?php echo $attendee->id; ?>"><?php echo htmlentities(stripslashes($attendee->firstName)." ".stripslashes($attendee->lastName)); ?></a> |
| 297 |
</td> |
| 298 |
<td><?php echo $attendee->rsvpStatus; ?></td> |
| 299 |
<?php if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {?> |
| 300 |
<td><?php |
| 301 |
if($attendee->rsvpStatus == "NoResponse") { |
| 302 |
echo "--"; |
| 303 |
} else { |
| 304 |
echo (($attendee->kidsMeal == "Y") ? "Yes" : "No"); |
| 305 |
}?></td> |
| 306 |
<?php } ?> |
| 307 |
<td><?php |
| 308 |
if($attendee->rsvpStatus == "NoResponse") { |
| 309 |
echo "--"; |
| 310 |
} else { |
| 311 |
echo (($attendee->additionalAttendee == "Y") ? "Yes" : "No"); |
| 312 |
} |
| 313 |
?></td> |
| 314 |
<?php if(get_option(OPTION_HIDE_VEGGIE) != "Y") {?> |
| 315 |
<td><?php |
| 316 |
if($attendee->rsvpStatus == "NoResponse") { |
| 317 |
echo "--"; |
| 318 |
} else { |
| 319 |
echo (($attendee->veggieMeal == "Y") ? "Yes" : "No"); |
| 320 |
} |
| 321 |
?></td> |
| 322 |
<?php } ?> |
| 323 |
<td><?php |
| 324 |
echo nl2br(stripslashes(trim($attendee->note))); |
| 325 |
?></td> |
| 326 |
<td> |
| 327 |
<?php |
| 328 |
$sql = "SELECT firstName, lastName FROM ".ATTENDEES_TABLE." |
| 329 |
WHERE id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 330 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)"; |
| 331 |
|
| 332 |
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendee->id, $attendee->id)); |
| 333 |
foreach($associations as $a) { |
| 334 |
echo htmlentities($a->firstName." ".$a->lastName)."<br />"; |
| 335 |
} |
| 336 |
?> |
| 337 |
</td> |
| 338 |
</tr> |
| 339 |
<?php |
| 340 |
$i++; |
| 341 |
} |
| 342 |
?> |
| 343 |
</table> |
| 344 |
</div> |
| 345 |
</form> |
| 346 |
</div> |
| 347 |
<?php |
| 348 |
} |
| 349 |
|
| 350 |
function rsvp_admin_export() { |
| 351 |
global $wpdb; |
| 352 |
$sql = "SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal |
| 353 |
FROM ".ATTENDEES_TABLE. |
| 354 |
" ORDER BY lastName, firstName"; |
| 355 |
$attendees = $wpdb->get_results($sql); |
| 356 |
$csv = "\"Attendee\",\"RSVP Status\","; |
| 357 |
|
| 358 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 359 |
$csv .= "\"Kids Meal\","; |
| 360 |
} |
| 361 |
$csv .= "\"Additional Attendee\","; |
| 362 |
|
| 363 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 364 |
$csv .= "\"Vegatarian\","; |
| 365 |
} |
| 366 |
$csv .= "\"Note\",\"Associated Attendees\"\r\n"; |
| 367 |
|
| 368 |
foreach($attendees as $a) { |
| 369 |
$csv .= "\"".stripslashes($a->firstName." ".$a->lastName)."\",\"".($a->rsvpStatus)."\","; |
| 370 |
|
| 371 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 372 |
$csv .= "\"".(($a->kidsMeal == "Y") ? "Yes" : "No")."\","; |
| 373 |
} |
| 374 |
|
| 375 |
$csv .= "\"".(($a->additionalAttendee == "Y") ? "Yes" : "No")."\","; |
| 376 |
|
| 377 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 378 |
$csv .= "\"".(($a->veggieMeal == "Y") ? "Yes" : "No")."\","; |
| 379 |
} |
| 380 |
|
| 381 |
$csv .= "\"".(str_replace("\"", "\"\"", stripslashes($a->note)))."\",\""; |
| 382 |
|
| 383 |
$sql = "SELECT firstName, lastName FROM ".ATTENDEES_TABLE." |
| 384 |
WHERE id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 385 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)"; |
| 386 |
|
| 387 |
$associations = $wpdb->get_results($wpdb->prepare($sql, $a->id, $a->id)); |
| 388 |
foreach($associations as $a) { |
| 389 |
$csv .= stripslashes($a->firstName." ".$a->lastName)."\r\n"; |
| 390 |
} |
| 391 |
$csv .= "\"\r\n"; |
| 392 |
} |
| 393 |
if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) { |
| 394 |
// IE Bug in download name workaround |
| 395 |
ini_set( 'zlib.output_compression','Off' ); |
| 396 |
} |
| 397 |
header('Content-Description: RSVP Export'); |
| 398 |
header("Content-Type: application/vnd.ms-excel", true); |
| 399 |
header('Content-Disposition: attachment; filename="rsvpEntries.csv"'); |
| 400 |
echo $csv; |
| 401 |
exit(); |
| 402 |
} |
| 403 |
|
| 404 |
function rsvp_admin_import() { |
| 405 |
global $wpdb; |
| 406 |
|
| 407 |
if((count($_FILES) > 0) && ($_FILES['importFile']['type'] == "application/msexcel")) { |
| 408 |
check_admin_referer('rsvp-import'); |
| 409 |
require_once("Excel/reader.php"); |
| 410 |
$data = new Spreadsheet_Excel_Reader(); |
| 411 |
$data->read($_FILES['importFile']['tmp_name']); |
| 412 |
if($data->sheets[0]['numCols'] >= 2) { |
| 413 |
$count = 0; |
| 414 |
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { |
| 415 |
$fName = trim($data->sheets[0]['cells'][$i][1]); |
| 416 |
$lName = trim($data->sheets[0]['cells'][$i][2]); |
| 417 |
if(!empty($fName) && !empty($lName)) { |
| 418 |
$wpdb->insert(ATTENDEES_TABLE, array("firstName" => $fName, "lastName" => $lName), array('%s', '%s')); |
| 419 |
$count++; |
| 420 |
} |
| 421 |
} |
| 422 |
?> |
| 423 |
<p><strong><?php echo $count; ?></strong> total records were imported.</p> |
| 424 |
<p>Continue to the RSVP <a href="admin.php?page=rsvp-top-level">list</a></p> |
| 425 |
<?php |
| 426 |
} |
| 427 |
} else { |
| 428 |
?> |
| 429 |
<form name="rsvp_import" method="post" enctype="multipart/form-data"> |
| 430 |
<?php wp_nonce_field('rsvp-import'); ?> |
| 431 |
<p>Select an excel file with the first name in <strong>column A</strong> and the last name in <strong>column B</strong>. A header row is not expected</p> |
| 432 |
<p><input type="file" name="importFile" id="importFile" /></p> |
| 433 |
<p><input type="submit" value="Import File" name="goRsvp" /></p> |
| 434 |
</form> |
| 435 |
<?php |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
function rsvp_admin_guest() { |
| 440 |
global $wpdb; |
| 441 |
if((count($_POST) > 0) && !empty($_POST['firstName']) && !empty($_POST['lastName'])) { |
| 442 |
check_admin_referer('rsvp_add_guest'); |
| 443 |
if(isset($_SESSION[EDIT_SESSION_KEY]) && is_numeric($_SESSION[EDIT_SESSION_KEY])) { |
| 444 |
$wpdb->update(ATTENDEES_TABLE, |
| 445 |
array("firstName" => trim($_POST['firstName']), "lastName" => trim($_POST['lastName'])), |
| 446 |
array("id" => $_SESSION[EDIT_SESSION_KEY]), |
| 447 |
array("%s", "%s"), |
| 448 |
array("%d")); |
| 449 |
$attendeeId = $_SESSION[EDIT_SESSION_KEY]; |
| 450 |
$wpdb->query($wpdb->prepare("DELETE FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeId = %d", $attendeeId)); |
| 451 |
} else { |
| 452 |
$wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($_POST['firstName']), "lastName" => trim($_POST['lastName'])), array('%s', '%s')); |
| 453 |
$attendeeId = $wpdb->insert_id; |
| 454 |
} |
| 455 |
foreach($_POST['associatedAttendees'] as $aid) { |
| 456 |
if(is_numeric($aid) && ($aid > 0)) { |
| 457 |
$wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID"=>$attendeeId, "associatedAttendeeID"=>$aid), array("%d", "%d")); |
| 458 |
} |
| 459 |
} |
| 460 |
?> |
| 461 |
<p>Attendee <?php echo htmlentities($_POST['firstName']." ".$_POST['lastName']);?> has been successfully saved</p> |
| 462 |
<p> |
| 463 |
<a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=rsvp-top-level">Continue to Attendee List</a> | |
| 464 |
<a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=rsvp-admin-guest">Add a Guest</a> |
| 465 |
</p> |
| 466 |
<?php |
| 467 |
} else { |
| 468 |
$attendee = null; |
| 469 |
session_unregister(EDIT_SESSION_KEY); |
| 470 |
$associatedAttendees = array(); |
| 471 |
$firstName = ""; |
| 472 |
$lastName = ""; |
| 473 |
|
| 474 |
if(isset($_GET['id']) && is_numeric($_GET['id'])) { |
| 475 |
$attendee = $wpdb->get_row("SELECT id, firstName, lastName FROM ".ATTENDEES_TABLE." WHERE id = ".$_GET['id']); |
| 476 |
if($attendee != null) { |
| 477 |
$_SESSION[EDIT_SESSION_KEY] = $attendee->id; |
| 478 |
$firstName = stripslashes($attendee->firstName); |
| 479 |
$lastName = stripslashes($attendee->lastName); |
| 480 |
|
| 481 |
// Get the associated attendees and add them to an array |
| 482 |
$associations = $wpdb->get_results("SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeId = ".$attendee->id. |
| 483 |
" UNION ". |
| 484 |
"SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = ".$attendee->id); |
| 485 |
foreach($associations as $aId) { |
| 486 |
$associatedAttendees[] = $aId->associatedAttendeeID; |
| 487 |
} |
| 488 |
} |
| 489 |
} |
| 490 |
?> |
| 491 |
<form name="contact" action="admin.php?page=rsvp-admin-guest" method="post"> |
| 492 |
<?php wp_nonce_field('rsvp_add_guest'); ?> |
| 493 |
<p class="submit"> |
| 494 |
<input type="submit" class="button-primary" value="<?php _e('Save'); ?>" /> |
| 495 |
</p> |
| 496 |
<table class="form-table"> |
| 497 |
<tr valign="top"> |
| 498 |
<th scope="row"><label for="firstName">First Name:</label></th> |
| 499 |
<td align="left"><input type="text" name="firstName" id="firstName" size="30" value="<?php echo htmlentities($firstName); ?>" /></td> |
| 500 |
</tr> |
| 501 |
<tr valign="top"> |
| 502 |
<th scope="row"><label for="lastName">Last Name:</label></th> |
| 503 |
<td align="left"><input type="text" name="lastName" id="lastName" size="30" value="<?php echo htmlentities($lastName); ?>" /></td> |
| 504 |
</tr> |
| 505 |
<tr valign="top"> |
| 506 |
<th scope="row">Associated Attendees:</th> |
| 507 |
<td align="left"> |
| 508 |
<select name="associatedAttendees[]" multiple="multiple" size="5" style="height: 2000px;"> |
| 509 |
<?php |
| 510 |
$attendees = $wpdb->get_results("SELECT id, firstName, lastName FROM ".$wpdb->prefix."attendees ORDER BY lastName, firstName"); |
| 511 |
foreach($attendees as $attendee) { |
| 512 |
if($attendee->id != $_SESSION[EDIT_SESSION_KEY]) { |
| 513 |
?> |
| 514 |
<option value="<?php echo $attendee->id; ?>" |
| 515 |
<?php echo ((in_array($attendee->id, $associatedAttendees)) ? "selected=\"selected\"" : ""); ?>><?php echo htmlentities(stripslashes($attendee->firstName)." ".stripslashes($attendee->lastName)); ?></option> |
| 516 |
<?php |
| 517 |
} |
| 518 |
} |
| 519 |
?> |
| 520 |
</select> |
| 521 |
</td> |
| 522 |
</tr> |
| 523 |
</table> |
| 524 |
<p class="submit"> |
| 525 |
<input type="submit" class="button-primary" value="<?php _e('Save'); ?>" /> |
| 526 |
</p> |
| 527 |
</form> |
| 528 |
<?php |
| 529 |
} |
| 530 |
} |
| 531 |
|
| 532 |
function rsvp_frontend_handler($text) { |
| 533 |
global $wpdb; |
| 534 |
|
| 535 |
//QUIT if the replacement string doesn't exist |
| 536 |
if (!strstr($text,FRONTEND_TEXT_CHECK)) return $text; |
| 537 |
|
| 538 |
// See if we should allow people to RSVP, etc... |
| 539 |
$openDate = get_option(OPTION_OPENDATE); |
| 540 |
$closeDate = get_option(OPTION_DEADLINE); |
| 541 |
if((strtotime($openDate) !== false) && (strtotime($openDate) > time())) { |
| 542 |
return "<p>I am sorry but the ability to RSVP for our wedding won't open till <strong>".date("m/d/Y", strtotime($openDate))."</strong></p>"; |
| 543 |
} |
| 544 |
|
| 545 |
if((strtotime($closeDate) !== false) && (strtotime($closeDate) < time())) { |
| 546 |
return "<p>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.</p>"; |
| 547 |
} |
| 548 |
|
| 549 |
if(isset($_POST['rsvpStep'])) { |
| 550 |
switch(strtolower($_POST['rsvpStep'])) { |
| 551 |
case("handlersvp") : |
| 552 |
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) { |
| 553 |
// update their information and what not.... |
| 554 |
if(strToUpper($_POST['mainRsvp']) == "Y") { |
| 555 |
$rsvpStatus = "Yes"; |
| 556 |
} else { |
| 557 |
$rsvpStatus = "No"; |
| 558 |
} |
| 559 |
$attendeeID = $_POST['attendeeID']; |
| 560 |
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"), |
| 561 |
"rsvpStatus" => $rsvpStatus, |
| 562 |
"note" => $_POST['note'], |
| 563 |
"kidsMeal" => ((strToUpper($_POST['mainKidsMeal']) == "Y") ? "Y" : "N"), |
| 564 |
"veggieMeal" => ((strToUpper($_POST['mainVeggieMeal']) == "Y") ? "Y" : "N")), |
| 565 |
array("id" => $attendeeID), |
| 566 |
array("%s", "%s", "%s", "%s", "%s"), |
| 567 |
array("%d")); |
| 568 |
$sql = "SELECT id FROM ".ATTENDEES_TABLE." |
| 569 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 570 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 571 |
AND rsvpStatus = 'NoResponse'"; |
| 572 |
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 573 |
foreach($associations as $a) { |
| 574 |
if($_POST['rsvpFor'.$a->id] == "Y") { |
| 575 |
if($_POST['attending'.$a->id] == "Y") { |
| 576 |
$rsvpStatus = "Yes"; |
| 577 |
} else { |
| 578 |
$rsvpStatus = "No"; |
| 579 |
} |
| 580 |
$wpdb->update(ATTENDEES_TABLE, array("rsvpDate" => date("Y-m-d"), |
| 581 |
"rsvpStatus" => $rsvpStatus, |
| 582 |
"kidsMeal" => ((strToUpper($_POST['attending'.$a->id.'KidsMeal']) == "Y") ? "Y" : "N"), |
| 583 |
"veggieMeal" => ((strToUpper($_POST['attending'.$a->id.'VeggieMeal']) == "Y") ? "Y" : "N")), |
| 584 |
array("id" => $a->id), |
| 585 |
array("%s", "%s", "%s", "%s"), |
| 586 |
array("%d")); |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
if(is_numeric($_POST['additionalRsvp']) && ($_POST['additionalRsvp'] > 0)) { |
| 591 |
for($i = 1; $i <= $_POST['additionalRsvp']; $i++) { |
| 592 |
if(($i <= 3) && |
| 593 |
!empty($_POST['newAttending'.$i.'FirstName']) && |
| 594 |
!empty($_POST['newAttending'.$i.'LastName'])) { |
| 595 |
$wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($_POST['newAttending'.$i.'FirstName']), |
| 596 |
"lastName" => trim($_POST['newAttending'.$i.'LastName']), |
| 597 |
"rsvpDate" => date("Y-m-d"), |
| 598 |
"rsvpStatus" => (($_POST['newAttending'.$i] == "Y") ? "Yes" : "No"), |
| 599 |
"kidsMeal" => $_POST['newAttending'.$i.'KidsMeal'], |
| 600 |
"veggieMeal" => $_POST['newAttending'.$i.'VeggieMeal'], |
| 601 |
"additionalAttendee" => "Y"), |
| 602 |
array('%s', '%s', '%s', '%s', '%s', '%s')); |
| 603 |
$newAid = $wpdb->insert_id; |
| 604 |
// Add associations for this new user |
| 605 |
$wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID" => $newAid, |
| 606 |
"associatedAttendeeID" => $attendeeID), |
| 607 |
array("%d", "%d")); |
| 608 |
$wpdb->query($wpdb->prepare("INSERT INTO ".ASSOCIATED_ATTENDEES_TABLE."(attendeeID, associatedAttendeeID) |
| 609 |
SELECT ".$newAid.", associatedAttendeeID |
| 610 |
FROM ".ASSOCIATED_ATTENDEES_TABLE." |
| 611 |
WHERE attendeeID = ".$attendeeID)); |
| 612 |
} |
| 613 |
} |
| 614 |
} |
| 615 |
|
| 616 |
return frontend_rsvp_thankyou(); |
| 617 |
} else { |
| 618 |
return rsvp_frontend_greeting(); |
| 619 |
} |
| 620 |
break; |
| 621 |
case("editattendee") : |
| 622 |
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) { |
| 623 |
// Try to find the user. |
| 624 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 625 |
FROM ".ATTENDEES_TABLE." |
| 626 |
WHERE id = %d", $_POST['attendeeID'])); |
| 627 |
if($attendee != null) { |
| 628 |
$output .= "<div>\r\n"; |
| 629 |
$output .= "<p>Welcome back ".htmlentities($attendee->firstName." ".$attendee->lastName)."!</p>"; |
| 630 |
$output .= rsvp_frontend_main_form($attendee->id); |
| 631 |
return $output."</div>\r\n"; |
| 632 |
} |
| 633 |
} |
| 634 |
break; |
| 635 |
case("foundattendee") : |
| 636 |
if(is_numeric($_POST['attendeeID']) && ($_POST['attendeeID'] > 0)) { |
| 637 |
// Try to find the user. |
| 638 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 639 |
FROM ".ATTENDEES_TABLE." |
| 640 |
WHERE id = %d", $_POST['attendeeID'])); |
| 641 |
if($attendee != null) { |
| 642 |
$output = "<div>\r\n"; |
| 643 |
if(strtolower($attendee->rsvpStatus) == "noresponse") { |
| 644 |
$output .= "<p>Hi ".htmlentities($attendee->firstName." ".$attendee->lastName)."!</p>". |
| 645 |
"<p>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.</p>"; |
| 646 |
$output .= rsvp_frontend_main_form($attendee->id); |
| 647 |
} else { |
| 648 |
$output .= rsvp_frontend_prompt_to_edit($attendee); |
| 649 |
} |
| 650 |
return $output."</div>\r\n"; |
| 651 |
} |
| 652 |
|
| 653 |
return rsvp_frontend_greeting(); |
| 654 |
} else { |
| 655 |
return rsvp_frontend_greeting(); |
| 656 |
} |
| 657 |
break; |
| 658 |
case("find") : |
| 659 |
$_SESSION['rsvpFirstName'] = $_POST['firstName']; |
| 660 |
$_SESSION['rsvpLastName'] = $_POST['lastName']; |
| 661 |
$firstName = $_POST['firstName']; |
| 662 |
$lastName = $_POST['lastName']; |
| 663 |
|
| 664 |
if((strlen($_POST['firstName']) <= 1) || (strlen($_POST['lastName']) <= 1)) { |
| 665 |
$output = "<p style=\"color:red\">A first and last name must be specified</p>\r\n"; |
| 666 |
$output .= rsvp_frontend_greeting(); |
| 667 |
|
| 668 |
return $output; |
| 669 |
} |
| 670 |
|
| 671 |
// Try to find the user. |
| 672 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus |
| 673 |
FROM ".ATTENDEES_TABLE." |
| 674 |
WHERE firstName = %s AND lastName = %s", $firstName, $lastName)); |
| 675 |
if($attendee != null) { |
| 676 |
// hey we found something, we should move on and print out any associated users and let them rsvp |
| 677 |
$output = "<div>\r\n"; |
| 678 |
if(strtolower($attendee->rsvpStatus) == "noresponse") { |
| 679 |
$output .= "<p>Hi ".htmlentities($attendee->firstName." ".$attendee->lastName)."!</p>". |
| 680 |
"<p>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.</p>"; |
| 681 |
$output .= rsvp_frontend_main_form($attendee->id); |
| 682 |
} else { |
| 683 |
$output .= rsvp_frontend_prompt_to_edit($attendee); |
| 684 |
} |
| 685 |
return $output."</div>\r\n"; |
| 686 |
} |
| 687 |
|
| 688 |
// We did not find anyone let's try and do a rough search |
| 689 |
$attendees = null; |
| 690 |
for($i = 3; $i >= 1; $i--) { |
| 691 |
$truncFirstName = rsvp_chomp_name($firstName, $i); |
| 692 |
$attendees = $wpdb->get_results("SELECT id, firstName, lastName, rsvpStatus FROM ".ATTENDEES_TABLE." |
| 693 |
WHERE lastName = '".mysql_real_escape_string($lastName)."' AND firstName LIKE '".mysql_real_escape_string($truncFirstName)."%'"); |
| 694 |
if(count($attendees) > 0) { |
| 695 |
$output = "<p><strong>We could not find an exact match but could any of the below entries be you?</strong></p>"; |
| 696 |
foreach($attendees as $a) { |
| 697 |
$output .= "<form method=\"post\">\r\n |
| 698 |
<input type=\"hidden\" name=\"rsvpStep\" value=\"foundattendee\" />\r\n |
| 699 |
<input type=\"hidden\" name=\"attendeeID\" value=\"".$a->id."\" />\r\n |
| 700 |
<p style=\"text-align:left;\">\r\n |
| 701 |
".htmlentities($a->firstName." ".$a->lastName)." |
| 702 |
<input type=\"submit\" value=\"RSVP\" />\r\n |
| 703 |
</p>\r\n</form>\r\n"; |
| 704 |
} |
| 705 |
|
| 706 |
return $output; |
| 707 |
} else { |
| 708 |
$i = strlen($truncFirstName); |
| 709 |
} |
| 710 |
} |
| 711 |
return "<p><strong>We were unable to find anyone with a name of ".htmlentities($firstName." ".$lastName)."</strong></p>\r\n".rsvp_frontend_greeting(); |
| 712 |
break; |
| 713 |
case("newsearch"): |
| 714 |
default: |
| 715 |
return rsvp_frontend_greeting(); |
| 716 |
break; |
| 717 |
} |
| 718 |
} else { |
| 719 |
return rsvp_frontend_greeting(); |
| 720 |
} |
| 721 |
} |
| 722 |
|
| 723 |
function rsvp_frontend_prompt_to_edit($attendee) { |
| 724 |
$prompt = "<p>Hi ".htmlentities($attendee->firstName." ".$attendee->lastName)." it looks like you have already RSVP'd. |
| 725 |
Would you like to edit your reservation?</p>"; |
| 726 |
$prompt .= "<form method=\"post\">\r\n |
| 727 |
<input type=\"hidden\" name=\"attendeeID\" value=\"".$attendee->id."\" /> |
| 728 |
<input type=\"hidden\" name=\"rsvpStep\" id=\"rsvpStep\" value=\"editattendee\" /> |
| 729 |
<input type=\"submit\" value=\"Yes\" onclick=\"document.getElementById('rsvpStep').value='editattendee';\" /> |
| 730 |
<input type=\"submit\" value=\"No\" onclick=\"document.getElementById('rsvpStep').value='newsearch';\" /> |
| 731 |
</form>\r\n"; |
| 732 |
return $prompt; |
| 733 |
} |
| 734 |
|
| 735 |
function rsvp_frontend_main_form($attendeeID) { |
| 736 |
global $wpdb; |
| 737 |
$attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal |
| 738 |
FROM ".ATTENDEES_TABLE." |
| 739 |
WHERE id = %d", $attendeeID)); |
| 740 |
$sql = "SELECT id FROM ".ATTENDEES_TABLE." |
| 741 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 742 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 743 |
AND additionalAttendee = 'Y'"; |
| 744 |
$newRsvps = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 745 |
|
| 746 |
|
| 747 |
$form = "<script type=\"text/javascript\" language=\"javascript\" src=\"".get_option("siteurl")."/wp-content/plugins/rsvp/jquery.js\"></script>\r\n"; |
| 748 |
$form .= "<script type=\"text/javascript\" language=\"javascript\" src=\"".get_option("siteurl")."/wp-content/plugins/rsvp/jquery-validate/jquery.validate.min.js\"></script>"; |
| 749 |
$form .= "<script type=\"text/javascript\" language=\"javascript\">\r\n |
| 750 |
$(document).ready(function(){ |
| 751 |
jQuery.validator.addMethod(\"customNote\", function(value, element) { |
| 752 |
if(($(\"#additionalRsvp\").val() > 0) && ($(\"#note\").val() == \"\")) { |
| 753 |
return false; |
| 754 |
} |
| 755 |
|
| 756 |
return true; |
| 757 |
}, \"<br />Please enter an email address that we can use to contact you about the extra guest. We have to keep a pretty close eye on the number of attendees. Thanks!\"); |
| 758 |
|
| 759 |
$(\"#rsvpForm\").validate({\r\n |
| 760 |
rules: { |
| 761 |
note: \"customNote\", |
| 762 |
newAttending1LastName: \"required\", |
| 763 |
newAttending1FirstName: \"required\", |
| 764 |
newAttending2LastName: \"required\", |
| 765 |
newAttending2FirstName: \"required\", |
| 766 |
newAttending3LastName: \"required\", |
| 767 |
newAttending3FirstName: \"required\" |
| 768 |
}, |
| 769 |
messages: { |
| 770 |
note: \"<br />If you are adding additional RSVPs please enter your email address in case we have questions\", |
| 771 |
newAttending1LastName: \"<br />Please enter a last name\", |
| 772 |
newAttending1FirstName: \"<br />Please enter a first name\", |
| 773 |
newAttending2LastName: \"<br />Please enter a last name\", |
| 774 |
newAttending2FirstName: \"<br />Please enter a first name\", |
| 775 |
newAttending3LastName: \"<br />Please enter a last name\", |
| 776 |
newAttending3FirstName: \"<br />Please enter a first name\" |
| 777 |
} |
| 778 |
}); |
| 779 |
}); |
| 780 |
</script>\r\n"; |
| 781 |
$form .= "<style text/css>\r\n". |
| 782 |
" label.error { font-weight: bold; clear:both;}\r\n". |
| 783 |
" input.error, textarea.error { border: 2px solid red; }\r\n". |
| 784 |
"</style>\r\n"; |
| 785 |
$form .= "<form id=\"rsvpForm\" name=\"rsvpForm\" method=\"post\">\r\n"; |
| 786 |
$form .= " <input type=\"hidden\" name=\"attendeeID\" value=\"".$attendeeID."\" />\r\n"; |
| 787 |
$form .= " <input type=\"hidden\" name=\"rsvpStep\" value=\"handleRsvp\" />\r\n"; |
| 788 |
$form .= "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\r\n"; |
| 789 |
$yesVerbiage = ((trim(get_option(OPTION_YES_VERBIAGE)) != "") ? get_option(OPTION_YES_VERBIAGE) : |
| 790 |
"Yes, of course I will be there! Who doesn't like family, friends, weddings, and a good time?"); |
| 791 |
$noVerbiage = ((trim(get_option(OPTION_NO_VERBIAGE)) != "") ? get_option(OPTION_NO_VERBIAGE) : |
| 792 |
"Um, unfortunately, there is a Star Trek marathon on that day that I just cannot miss."); |
| 793 |
$kidsVerbiage = ((trim(get_option(OPTION_KIDS_MEAL_VERBIAGE)) != "") ? get_option(OPTION_KIDS_MEAL_VERBIAGE) : |
| 794 |
"We have the option of getting cheese pizza for the kids (and only kids). Do you want pizza instead of \"adult food?\""); |
| 795 |
$veggieVerbiage = ((trim(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)) != "") ? get_option(OPTION_VEGGIE_MEAL_VERBIAGE) : |
| 796 |
"We also have the option of getting individual vegetarian meals instead of the fish or meat. Would you like a vegetarian dinner?"); |
| 797 |
$noteVerbiage = ((trim(get_option(OPTION_NOTE_VERBIAGE)) != "") ? get_option(OPTION_NOTE_VERBIAGE) : |
| 798 |
"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 at <a href=\"mailto:rsvp@janaandmike.com\">rsvp@janaandmike.com</a>."); |
| 799 |
$form .= " <tr>\r\n |
| 800 |
<td align=\"left\">So, how about it?</td> |
| 801 |
</tr>\r\n |
| 802 |
<tr>\r\n |
| 803 |
<td colspan=\"2\" align=\"left\"><input type=\"radio\" name=\"mainRsvp\" value=\"Y\" id=\"mainRsvpY\" ". |
| 804 |
(($attendee->rsvpStatus == "No") ? "" : "checked=\"checked\"")." /> - <label for=\"mainRsvpY\">".htmlentities($yesVerbiage)."</label></td> |
| 805 |
</tr>\r\n |
| 806 |
<tr>\r\n |
| 807 |
<td align=\"left\" colspan=\"2\"><input type=\"radio\" name=\"mainRsvp\" value=\"N\" id=\"mainRsvpN\" ". |
| 808 |
(($attendee->rsvpStatus == "No") ? "checked=\"checked\"" : "")." > - |
| 809 |
<label for=\"mainRsvpN\">".htmlentities($noVerbiage)."</label></td> |
| 810 |
</tr>"; |
| 811 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 812 |
$form .= " <tr><td colspan=\"2\"><hr /></td></tr>\r\n |
| 813 |
<tr>\r\n |
| 814 |
<td colspan=\"2\" align=\"left\">".htmlentities($kidsVerbiage)."</td> |
| 815 |
</tr>\r\n |
| 816 |
<tr>\r\n |
| 817 |
<td align=\"center\" colspan=\"2\"><input type=\"radio\" name=\"mainKidsMeal\" value=\"Y\" id=\"mainKidsMealY\" |
| 818 |
".(($attendee->kidsMeal == "Y") ? "checked=\"checked\"" : "")." /> <label for=\"mainKidsMealY\">Yes</label> |
| 819 |
<input type=\"radio\" name=\"mainKidsMeal\" value=\"N\" id=\"mainKidsMealN\" |
| 820 |
".(($attendee->kidsMeal == "Y") ? "" : "checked=\"checked\"")." /> <label for=\"mainKidsMealN\">No</label></td> |
| 821 |
</tr>"; |
| 822 |
} |
| 823 |
|
| 824 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 825 |
$form .= " <tr><td colspan=\"2\"><hr /></td></tr>\r\n |
| 826 |
<tr>\r\n |
| 827 |
<td align=\"left\" colspan=\"2\">".htmlentities($veggieVerbiage)."</td> |
| 828 |
</tr>\r\n |
| 829 |
<tr>\r\n |
| 830 |
<td align=\"center\" colspan=\"2\"><input type=\"radio\" name=\"mainVeggieMeal\" value=\"Y\" id=\"mainVeggieMealY\" |
| 831 |
".(($attendee->veggieMeal == "Y") ? "checked=\"checked\"" : "")."/> <label for=\"mainVeggieMealY\">Yes</label> |
| 832 |
<input type=\"radio\" name=\"mainVeggieMeal\" value=\"N\" id=\"mainVeggieMealN\" |
| 833 |
".(($attendee->veggieMeal == "Y") ? "" : "checked=\"checked\"")." /> <label for=\"mainVeggieMealN\">No</label></td> |
| 834 |
</tr>\r\n"; |
| 835 |
} |
| 836 |
|
| 837 |
$form .= " <tr><td><br /></td></tr>\r\n |
| 838 |
<tr> |
| 839 |
<td valign=\"top\" align=\"left\" colspan=\"2\">".$noteVerbiage."</td> |
| 840 |
</tr> |
| 841 |
<tr> |
| 842 |
<td colspan=\"2\"><textarea name=\"note\" id=\"note\" rows=\"7\" cols=\"50\">".htmlentities($attendee->note)."</textarea></td> |
| 843 |
</tr>"; |
| 844 |
$form .= "</table>\r\n"; |
| 845 |
|
| 846 |
$sql = "SELECT id, firstName, lastName FROM ".ATTENDEES_TABLE." |
| 847 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 848 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 849 |
AND rsvpStatus <> 'NoResponse'"; |
| 850 |
$rsvpd = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 851 |
if(count($rsvpd) > 0) { |
| 852 |
$form .= "<p>The following people associated with you have already registered: "; |
| 853 |
foreach($rsvpd as $r) { |
| 854 |
$form .= "<br />".htmlentities($r->firstName." ".$r->lastName); |
| 855 |
} |
| 856 |
$form .= "</p>\r\n"; |
| 857 |
} |
| 858 |
|
| 859 |
$sql = "SELECT id, firstName, lastName FROM ".ATTENDEES_TABLE." |
| 860 |
WHERE (id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d) |
| 861 |
OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)) |
| 862 |
AND rsvpStatus = 'NoResponse'"; |
| 863 |
|
| 864 |
$associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID)); |
| 865 |
if(count($associations) > 0) { |
| 866 |
$form .= "<h3>The following people are associated with you. At this time you can RSVP for them as well.</h3>"; |
| 867 |
foreach($associations as $a) { |
| 868 |
$form .= "<div style=\"text-align:left;border-top: 1px solid;\">\r\n |
| 869 |
<p><label for=\"rsvpFor".$a->id."\">RSVP for ".htmlentities($a->firstName." ".$a->lastName)."?</label> |
| 870 |
<input type=\"checkbox\" name=\"rsvpFor".$a->id."\" id=\"rsvpFor".$a->id."\" value=\"Y\" /></p>"; |
| 871 |
|
| 872 |
$form .= "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\r\n"; |
| 873 |
$form .= " <tr>\r\n |
| 874 |
<td align=\"left\">Will ".htmlentities($a->firstName)." be attending?</td>\r\n |
| 875 |
<td align=\"left\"><input type=\"radio\" name=\"attending".$a->id."\" value=\"Y\" id=\"attending".$a->id."Y\" checked=\"checked\" /> |
| 876 |
<label for=\"attending".$a->id."Y\">Yes</label> |
| 877 |
<input type=\"radio\" name=\"attending".$a->id."\" value=\"N\" id=\"attending".$a->id."N\"> <label for=\"attending".$a->id."N\">No</label></td> |
| 878 |
</tr>"; |
| 879 |
|
| 880 |
if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") { |
| 881 |
$form .= " <tr> |
| 882 |
<td align=\"left\">Does ".htmlentities($a->firstName)." need a kids meal? </td> |
| 883 |
<td align=\"left\"><input type=\"radio\" name=\"attending".$a->id."KidsMeal\" value=\"Y\" id=\"attending".$a->id."KidsMealY\" /> |
| 884 |
<label for=\"attending".$a->id."KidsMealY\">Yes</label> |
| 885 |
<input type=\"radio\" name=\"attending".$a->id."KidsMeal\" value=\"N\" id=\"attending".$a->id."KidsMealN\" checked=\"checked\" /> |
| 886 |
<label for=\"attending".$a->id."KidsMealN\">No</label></td> |
| 887 |
</tr>"; |
| 888 |
} |
| 889 |
|
| 890 |
if(get_option(OPTION_HIDE_VEGGIE) != "Y") { |
| 891 |
$form .= " <tr> |
| 892 |
<td align=\"left\">Does ".htmlentities($a->firstName)." need a vegetarian meal? </td> |
| 893 |
<td align=\"left\"><input type=\"radio\" name=\"attending".$a->id."VeggieMeal\" value=\"Y\" id=\"attending".$a->id."VeggieMealY\" /> |
| 894 |
<label for=\"attending".$a->id."VeggieMealY\">Yes</label> |
| 895 |
<input type=\"radio\" name=\"attending".$a->id."VeggieMeal\" value=\"N\" id=\"attending".$a->id."VeggieMealN\" checked=\"checked\" /> |
| 896 |
<label for=\"attending".$a->id."VeggieMealN\">No</label></td> |
| 897 |
</tr>"; |
| 898 |
} |
| 899 |
$form .= "</table>\r\n"; |
| 900 |
$form .= "</div>\r\n"; |
| 901 |
} |
| 902 |
} |
| 903 |
$form .= "<h3>Did we slip up and forget to invite someone? If so, please add him or her here:</h3>\r\n"; |
| 904 |
$form .= "<div id=\"additionalRsvpContainer\">\r\n |
| 905 |
<input type=\"hidden\" name=\"additionalRsvp\" id=\"additionalRsvp\" value=\"".count($newRsvps)."\" /> |
| 906 |
<div style=\"text-align:right\"><img |
| 907 |
src=\"".get_option("siteurl")."/wp-content/plugins/rsvp/plus.png\" width=\"24\" height=\"24\" border=\"0\" id=\"addRsvp\" /></div> |
| 908 |
|
| 909 |
</div>"; |
| 910 |
|
| 911 |
$form .= "<p><input type=\"submit\" value=\"RSVP\" /></p>\r\n"; |
| 912 |
$form .= "<script type=\"text/javascript\" language=\"javascript\">\r\n |
| 913 |
$(document).ready(function() { |
| 914 |
$(\"#addRsvp\").click(function() { |
| 915 |
handleAddRsvpClick(); |
| 916 |
}); |
| 917 |
}); |
| 918 |
|
| 919 |
function handleAddRsvpClick() { |
| 920 |
var numAdditional = $(\"#additionalRsvp\").val(); |
| 921 |
numAdditional++; |
| 922 |
if(numAdditional > 3) { |
| 923 |
alert('You have already added 3 additional rsvp\'s you can add no more.'); |
| 924 |
} else { |
| 925 |
$(\"#additionalRsvpContainer\").append(\"<div style=\\\"text-align:left;border-top: 1px solid;\\\">\" + \r\n |
| 926 |
\"<table cellpadding=\\\"2\\\" cellspacing=\\\"0\\\" border=\\\"0\\\">\" + \r\n |
| 927 |
\"<tr>\" + \r\n |
| 928 |
\" <td align=\\\"left\\\">Person's first name </td>\" + \r\n |
| 929 |
\" <td align=\\\"left\\\"><input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"FirstName\\\" id=\\\"newAttending\" + numAdditional + \"FirstName\\\" /></td>\" + \r\n |
| 930 |
\"</tr>\" + \r\n |
| 931 |
\"<tr>\" + \r\n |
| 932 |
\" <td align=\\\"left\\\">Person's last name</td>\" + \r\n |
| 933 |
\" <td align=\\\"left\\\"><input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"LastName\\\" id=\\\"newAttending\" + numAdditional + \"LastName\\\" /></td>\" + \r\n |
| 934 |
\"</tr>\" + \r\n |
| 935 |
\"<tr>\" + \r\n |
| 936 |
\"<td align=\\\"left\\\">Will this person be attending? </td>\" + \r\n |
| 937 |
\"<td align=\\\"left\\\">\" + |
| 938 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"Y\\\" checked=\\\"checked\\\" /> \" + |
| 939 |
\"<label for=\\\"newAttending\" + numAdditional + \"Y\\\">Yes</label> \" + |
| 940 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"N\\\"> <label for=\\\"newAttending\" + numAdditional + \"N\\\">No</label></td>\" + |
| 941 |
\"</tr>\" + |
| 942 |
\"<tr>\" + |
| 943 |
\"<td align=\\\"left\\\">Does this person need a kids meal? </td> \" + |
| 944 |
\"<td align=\\\"left\\\"><input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealY\\\" /> \" + |
| 945 |
\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealY\\\">Yes</label> \" + |
| 946 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealN\\\" checked=\\\"checked\\\" /> \" + |
| 947 |
\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealN\\\">No</label></td>\" + |
| 948 |
\"</tr>\" + |
| 949 |
\"<tr>\" + |
| 950 |
\"<td align=\\\"left\\\">Does this person need a vegetarian meal? </td> \" + |
| 951 |
\"<td align=\\\"left\\\"><input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\" /> \" + |
| 952 |
\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\">Yes</label> \" + |
| 953 |
\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\" checked=\\\"checked\\\" /> \" + |
| 954 |
\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\">No</label></td>\" + |
| 955 |
\"</tr>\" + |
| 956 |
\"</table>\" + |
| 957 |
\"<br />\" + |
| 958 |
\"</div>\"); |
| 959 |
$(\"#additionalRsvp\").val(numAdditional); |
| 960 |
} |
| 961 |
} |
| 962 |
</script>\r\n"; |
| 963 |
$form .= "</form>\r\n"; |
| 964 |
|
| 965 |
return $form; |
| 966 |
} |
| 967 |
|
| 968 |
function frontend_rsvp_thankyou() { |
| 969 |
$customTy = get_option(OPTION_THANKYOU); |
| 970 |
if(!empty($customTy)) { |
| 971 |
return nl2br($customTy); |
| 972 |
} else { |
| 973 |
return "<p>Thank you for RSVPing</p>"; |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
function rsvp_chomp_name($name, $maxLength) { |
| 978 |
for($i = $maxLength; $maxLength >= 1; $i--) { |
| 979 |
if(strlen($name) >= $i) { |
| 980 |
return substr($name, 0, $i); |
| 981 |
} |
| 982 |
} |
| 983 |
} |
| 984 |
|
| 985 |
function rsvp_frontend_greeting() { |
| 986 |
$customGreeting = get_option(OPTION_GREETING); |
| 987 |
$output = "<p>Please enter your first and last name to RSVP.</p>"; |
| 988 |
if(!empty($customGreeting)) { |
| 989 |
$output = nl2br($customGreeting); |
| 990 |
} |
| 991 |
$output .= "<script type=\"text/javascript\" language=\"javascript\" src=\"".get_option("siteurl")."/wp-content/plugins/rsvp/jquery.js\"></script>"; |
| 992 |
$output .= "<script type=\"text/javascript\" language=\"javascript\" src=\"".get_option("siteurl")."/wp-content/plugins/rsvp/jquery-validate/jquery.validate.min.js\"></script>"; |
| 993 |
$output .= "<script type=\"text/javascript\">$(document).ready(function(){ $(\"#rsvp\").validate({rules: {firstName: \"required\",lastName: \"required\"}, messages: {firstName: \"<br />Please enter your first name\", lastName: \"<br />Please enter your last name\"}});});</script>"; |
| 994 |
$output .= "<style text/css>\r\n". |
| 995 |
" label.error { font-weight: bold; clear:both;}\r\n". |
| 996 |
" input.error { border: 2px solid red; }\r\n". |
| 997 |
"</style>\r\n"; |
| 998 |
$output .= "<form name=\"rsvp\" method=\"post\" id=\"rsvp\">\r\n"; |
| 999 |
$output .= " <input type=\"hidden\" name=\"rsvpStep\" value=\"find\" />"; |
| 1000 |
$output .= "<p><label for=\"firstName\">First Name:</label> |
| 1001 |
<input type=\"text\" name=\"firstName\" id=\"firstName\" size=\"30\" value=\"".htmlentities($_SESSION['rsvpFirstName'])."\" class=\"required\" /></p>\r\n"; |
| 1002 |
$output .= "<p><label for=\"lastName\">Last Name:</label> |
| 1003 |
<input type=\"text\" name=\"lastName\" id=\"lastName\" size=\"30\" value=\"".htmlentities($_SESSION['rsvpLastName'])."\" class=\"required\" /></p>\r\n"; |
| 1004 |
$output .= "<p><input type=\"submit\" value=\"Register\" /></p>"; |
| 1005 |
$output .= "</form>\r\n"; |
| 1006 |
|
| 1007 |
return $output; |
| 1008 |
} |
| 1009 |
|
| 1010 |
function rsvp_modify_menu() { |
| 1011 |
|
| 1012 |
add_options_page('RSVP Options', //page title |
| 1013 |
'RSVP Options', //subpage title |
| 1014 |
'manage_options', //access |
| 1015 |
'rsvp-options', //current file |
| 1016 |
'rsvp_admin_guestlist_options' //options function above |
| 1017 |
); |
| 1018 |
add_menu_page("RSVP Plugin", |
| 1019 |
"RSVP Plugin", |
| 1020 |
"publish_posts", |
| 1021 |
"rsvp-top-level", |
| 1022 |
"rsvp_admin_guestlist"); |
| 1023 |
add_submenu_page("rsvp-top-level", |
| 1024 |
"Add Guest", |
| 1025 |
"Add Guest", |
| 1026 |
"publish_posts", |
| 1027 |
"rsvp-admin-guest", |
| 1028 |
"rsvp_admin_guest"); |
| 1029 |
add_submenu_page("rsvp-top-level", |
| 1030 |
"RSVP Export", |
| 1031 |
"RSVP Export", |
| 1032 |
"publish_posts", |
| 1033 |
"rsvp-admin-export", |
| 1034 |
"rsvp_admin_export"); |
| 1035 |
add_submenu_page("rsvp-top-level", |
| 1036 |
"RSVP Import", |
| 1037 |
"RSVP Import", |
| 1038 |
"publish_posts", |
| 1039 |
"rsvp-admin-import", |
| 1040 |
"rsvp_admin_import"); |
| 1041 |
} |
| 1042 |
|
| 1043 |
add_action('admin_menu', 'rsvp_modify_menu'); |
| 1044 |
add_filter('the_content', 'rsvp_frontend_handler'); |
| 1045 |
register_activation_hook(__FILE__,'rsvp_database_setup'); |
| 1046 |
?> |