PluginProbe
RSVP and Event Management / 1.6.0
RSVP and Event Management v1.6.0
trunk 0.5.0 0.6.0 0.7.0 0.8.0 0.9.0 0.9.5 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.5.0 1.6.0 1.6.1 1.6.2 1.6.5 1.7.0 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 All 136 releases
rsvp / wp-rsvp.php

wp-rsvp.php in RSVP and Event Management 1.6.0, at wp-rsvp.php

1,353 lines 59.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package rsvp
4 * @author MDE Development, LLC
5 * @version 1.6.0
6 */
7 /*
8 Plugin Name: RSVP
9 Text Domain: rsvp-plugin
10 Plugin URI: http://wordpress.org/#
11 Description: This plugin allows guests to RSVP to an event. It was made
12 initially for weddings but could be used for other things.
13 Author: MDE Development, LLC
14 Version: 1.6.0
15 Author URI: http://mde-dev.com
16 License: GPL
17 */
18 #
19 # INSTALLATION: see readme.txt
20 #
21 # USAGE: Once the RSVP plugin has been installed, you can set the custom text
22 # via Settings -> RSVP Options in the admin area.
23 #
24 # To add, edit, delete and see rsvp status there will be a new RSVP admin
25 # area just go there.
26 #
27 # To allow people to rsvp create a new page and add "rsvp-pluginhere" to the text
28
29 session_start();
30 define("ATTENDEES_TABLE", $wpdb->prefix."attendees");
31 define("ASSOCIATED_ATTENDEES_TABLE", $wpdb->prefix."associatedAttendees");
32 define("QUESTIONS_TABLE", $wpdb->prefix."rsvpCustomQuestions");
33 define("QUESTION_TYPE_TABLE", $wpdb->prefix."rsvpQuestionTypes");
34 define("ATTENDEE_ANSWERS", $wpdb->prefix."attendeeAnswers");
35 define("QUESTION_ANSWERS_TABLE", $wpdb->prefix."rsvpCustomQuestionAnswers");
36 define("QUESTION_ATTENDEES_TABLE", $wpdb->prefix."rsvpCustomQuestionAttendees");
37 define("EDIT_SESSION_KEY", "RsvpEditAttendeeID");
38 define("EDIT_QUESTION_KEY", "RsvpEditQuestionID");
39 define("RSVP_FRONTEND_TEXT_CHECK", "rsvp-pluginhere");
40 define("OPTION_GREETING", "rsvp_custom_greeting");
41 define("OPTION_THANKYOU", "rsvp_custom_thankyou");
42 define("OPTION_DEADLINE", "rsvp_deadline");
43 define("OPTION_OPENDATE", 'rsvp_opendate');
44 define("OPTION_YES_VERBIAGE", "rsvp_yes_verbiage");
45 define("OPTION_NO_VERBIAGE", "rsvp_no_verbiage");
46 define("OPTION_KIDS_MEAL_VERBIAGE", "rsvp_kids_meal_verbiage");
47 define("OPTION_VEGGIE_MEAL_VERBIAGE", "rsvp_veggie_meal_verbiage");
48 define("OPTION_NOTE_VERBIAGE", "rsvp_note_verbiage");
49 define("OPTION_HIDE_VEGGIE", "rsvp_hide_veggie");
50 define("OPTION_HIDE_KIDS_MEAL", "rsvp_hide_kids_meal");
51 define("OPTION_HIDE_ADD_ADDITIONAL", "rsvp_hide_add_additional");
52 define("OPTION_NOTIFY_ON_RSVP", "rsvp_notify_when_rsvp");
53 define("OPTION_NOTIFY_EMAIL", "rsvp_notify_email_address");
54 define("OPTION_DEBUG_RSVP_QUERIES", "rsvp_debug_queries");
55 define("OPTION_WELCOME_TEXT", "rsvp_custom_welcome");
56 define("OPTION_RSVP_QUESTION", "rsvp_custom_question_text");
57 define("OPTION_RSVP_CUSTOM_YES_NO", "rsvp_custom_yes_no");
58 define("OPTION_RSVP_PASSCODE", "rsvp_passcode");
59 define("RSVP_DB_VERSION", "9");
60 define("QT_SHORT", "shortAnswer");
61 define("QT_MULTI", "multipleChoice");
62 define("QT_LONG", "longAnswer");
63 define("QT_DROP", "dropdown");
64 define("QT_RADIO", "radio");
65 define("RSVP_START_PARA", "<p class=\"rsvpParagraph\">");
66 define("RSVP_END_PARA", "</p>\r\n");
67 define("RSVP_START_CONTAINER", "<div id=\"rsvpPlugin\">\r\n");
68 define("RSVP_END_CONTAINER", "</div>\r\n");
69 define("RSVP_START_FORM_FIELD", "<div class=\"rsvpFormField\">\r\n");
70 define("RSVP_END_FORM_FIELD", "</div>\r\n");
71
72 $my_plugin_file = __FILE__;
73
74 if (isset($plugin)) {
75 $my_plugin_file = $plugin;
76 }
77 else if (isset($mu_plugin)) {
78 $my_plugin_file = $mu_plugin;
79 }
80 else if (isset($network_plugin)) {
81 $my_plugin_file = $network_plugin;
82 }
83
84 define('RSVP_PLUGIN_FILE', $my_plugin_file);
85 define('RSVP_PLUGIN_PATH', WP_PLUGIN_DIR.'/'.basename(dirname($my_plugin_file)));
86 if((isset($_GET['page']) && (strToLower($_GET['page']) == 'rsvp-admin-export')) ||
87 (isset($_POST['rsvp-bulk-action']) && (strToLower($_POST['rsvp-bulk-action']) == "export"))) {
88 add_action('init', 'rsvp_admin_export');
89 }
90
91 require_once("rsvp_frontend.inc.php");
92 /*
93 * Description: Database setup for the rsvp plug-in.
94 */
95 function rsvp_database_setup() {
96 global $wpdb;
97 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
98 require_once("rsvp_db_setup.inc.php");
99 }
100
101 function rsvp_install_passcode_field() {
102 global $wpdb;
103 $table = ATTENDEES_TABLE;
104 $sql = "SHOW COLUMNS FROM `$table` LIKE 'passcode'";
105 if(!$wpdb->get_results($sql)) {
106 $sql = "ALTER TABLE `$table` ADD `passcode` VARCHAR(50) NOT NULL DEFAULT '';";
107 $wpdb->query($sql);
108 }
109 }
110
111 /**
112 * This generates a random 6 character passcode to be used for guests when the option is enabled.
113 */
114 function rsvp_generate_passcode() {
115 $length = 6;
116 $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
117 $passcode = "";
118
119 for ($p = 0; $p < $length; $p++) {
120 $passcode .= $characters[mt_rand(0, strlen($characters))];
121 }
122
123 return $passcode;
124 }
125
126 function rsvp_admin_guestlist_options() {
127
128 if(get_option(OPTION_RSVP_PASSCODE) == "Y") {
129 global $wpdb;
130
131 rsvp_install_passcode_field();
132
133 $sql = "SELECT id, passcode FROM ".ATTENDEES_TABLE." WHERE passcode = ''";
134 $attendees = $wpdb->get_results($sql);
135 foreach($attendees as $a) {
136 $newPasscode = rsvp_generate_passcode();
137 $wpdb->update(ATTENDEES_TABLE,
138 array("passcode" => rsvp_generate_passcode()),
139 array("id" => $a->id),
140 array("%s"),
141 array("%d"));
142 }
143 }
144 ?>
145 <script type="text/javascript" language="javascript">
146 jQuery(document).ready(function() {
147 jQuery("#rsvp_opendate").datepicker();
148 jQuery("#rsvp_deadline").datepicker();
149 });
150 </script>
151 <div class="wrap">
152 <h2>RSVP Guestlist Options</h2>
153 <form method="post" action="options.php">
154 <?php settings_fields( 'rsvp-option-group' ); ?>
155 <table class="form-table">
156 <tr valign="top">
157 <th scope="row"><label for="rsvp_opendate">RSVP Open Date:</label></th>
158 <td align="left"><input type="text" name="rsvp_opendate" id="rsvp_opendate" value="<?php echo htmlspecialchars(get_option(OPTION_OPENDATE)); ?>" /></td>
159 </tr>
160 <tr valign="top">
161 <th scope="row"><label for="rsvp_deadline">RSVP Deadline:</label></th>
162 <td align="left"><input type="text" name="rsvp_deadline" id="rsvp_deadline" value="<?php echo htmlspecialchars(get_option(OPTION_DEADLINE)); ?>" /></td>
163 </tr>
164 <tr valign="top">
165 <th scope="row"><label for="rsvp_custom_greeting">Custom Greeting:</label></th>
166 <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>
167 </tr>
168 <tr valign="top">
169 <th scope="row"><label for="rsvp_custom_welcome">Custom Welcome:</label></th>
170 <td align="left">Default is: &quot;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.&quot;<br />
171 <textarea name="rsvp_custom_welcome" id="rsvp_custom_welcome" rows="5" cols="60"><?php echo htmlspecialchars(get_option(OPTION_WELCOME_TEXT)); ?></textarea></td>
172 </tr>
173 <tr valign="top">
174 <th scope="row"><label for="rsvp_custom_question_text">RSVP Question Verbiage:</label></th>
175 <td align="left">Default is: &quot;So, how about it?&quot;<br />
176 <input type="text" name="rsvp_custom_question_text" id="rsvp_custom_question_text"
177 value="<?php echo htmlspecialchars(get_option(OPTION_RSVP_QUESTION)); ?>" size="65" /></td>
178 </tr>
179 <tr valign="top">
180 <th scope="row"><label for="rsvp_yes_verbiage">RSVP Yes Verbiage:</label></th>
181 <td align="left"><input type="text" name="rsvp_yes_verbiage" id="rsvp_yes_verbiage"
182 value="<?php echo htmlspecialchars(get_option(OPTION_YES_VERBIAGE)); ?>" size="65" /></td>
183 </tr>
184 <tr valign="top">
185 <th scope="row"><label for="rsvp_no_verbiage">RSVP No Verbiage:</label></th>
186 <td align="left"><input type="text" name="rsvp_no_verbiage" id="rsvp_no_verbiage"
187 value="<?php echo htmlspecialchars(get_option(OPTION_NO_VERBIAGE)); ?>" size="65" /></td>
188 </tr>
189 <!--<tr valign="top">
190 <th scope="row"><label for="rsvp_custom_yes_no">Custom Yes/No Questions</label></th>
191 <td align="left">
192 This option allows a user to add in multiple yes or no options for when a user rsvps. This will over ride anything specified for the "RSVP Yes Verbiage" and "RSVP No Verbiage" options. The format of each question should be in the format:<br />
193 value | Text user to see and each on it's own line.<br /><br />
194 An example:<br />
195 Yes | Yes, I will gladly come<br />
196 Eh | Eh, I don't really know you and I know you are only inviting me for a gift
197 <br /><br />
198 <strong>Note:</strong> If you do not set a question with a value of "Yes" and one with a value of "No" the RSVP "Yes" and "No" counts will not be correct.
199 <br /><br />
200 <textarea name="rsvp_custom_yes_no" id="rsvp_custom_yes_no" rows="5" cols="60"><?php echo htmlspecialchars(get_option(OPTION_RSVP_CUSTOM_YES_NO)); ?></textarea>
201 </td>
202 </tr>-->
203 <tr valign="top">
204 <th scope="row"><label for="rsvp_kids_meal_verbiage">RSVP Kids Meal Verbiage:</label></th>
205 <td align="left"><input type="text" name="rsvp_kids_meal_verbiage" id="rsvp_kids_meal_verbiage"
206 value="<?php echo htmlspecialchars(get_option(OPTION_KIDS_MEAL_VERBIAGE)); ?>" size="65" /></td>
207 </tr>
208 <tr valign="top">
209 <th scope="row"><label for="rsvp_hide_kids_meal">Hide Kids Meal Question:</label></th>
210 <td align="left"><input type="checkbox" name="rsvp_hide_kids_meal" id="rsvp_hide_kids_meal"
211 value="Y" <?php echo ((get_option(OPTION_HIDE_KIDS_MEAL) == "Y") ? " checked=\"checked\"" : ""); ?> /></td>
212 </tr>
213 <tr valign="top">
214 <th scope="row"><label for="rsvp_veggie_meal_verbiage">RSVP Vegetarian Meal Verbiage:</label></th>
215 <td align="left"><input type="text" name="rsvp_veggie_meal_verbiage" id="rsvp_veggie_meal_verbiage"
216 value="<?php echo htmlspecialchars(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)); ?>" size="65" /></td>
217 </tr>
218 <tr valign="top">
219 <th scope="row"><label for="rsvp_hide_veggie">Hide Vegetarian Meal Question:</label></th>
220 <td align="left"><input type="checkbox" name="rsvp_hide_veggie" id="rsvp_hide_veggie"
221 value="Y" <?php echo ((get_option(OPTION_HIDE_VEGGIE) == "Y") ? " checked=\"checked\"" : ""); ?> /></td>
222 </tr>
223 <tr valign="top">
224 <th scope="row"><label for="rsvp_note_verbiage">Note Verbiage:</label></th>
225 <td align="left"><textarea name="rsvp_note_verbiage" id="rsvp_note_verbiage" rows="3" cols="60"><?php
226 echo htmlspecialchars(get_option(OPTION_NOTE_VERBIAGE)); ?></textarea></td>
227 </tr>
228 <tr valign="top">
229 <th scope="row"><label for="rsvp_custom_thankyou">Custom Thank You:</label></th>
230 <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>
231 </tr>
232 <tr>
233 <th scope="row"><label for="rsvp_hide_add_additional">Do not allow additional guests</label></th>
234 <td align="left"><input type="checkbox" name="rsvp_hide_add_additional" id="rsvp_hide_add_additional" value="Y"
235 <?php echo ((get_option(OPTION_HIDE_ADD_ADDITIONAL) == "Y") ? " checked=\"checked\"" : ""); ?> /></td>
236 </tr>
237 <tr>
238 <th scope="row"><label for="rsvp_notify_when_rsvp">Notify When Guest RSVPs</label></th>
239 <td align="left"><input type="checkbox" name="rsvp_notify_when_rsvp" id="rsvp_notify_when_rsvp" value="Y"
240 <?php echo ((get_option(OPTION_NOTIFY_ON_RSVP) == "Y") ? " checked=\"checked\"" : ""); ?> /></td>
241 </tr>
242 <tr>
243 <th scope="row"><label for="rsvp_notify_email_address">Email address to notify</label></th>
244 <td align="left"><input type="text" name="rsvp_notify_email_address" id="rsvp_notify_email_address" value="<?php echo htmlspecialchars(get_option(OPTION_NOTIFY_EMAIL)); ?>"/></td>
245 </tr>
246 <tr>
247 <th scope="ropw"><label for="<?php echo OPTION_RSVP_PASSCODE; ?>">Require a Passcode to RSVP:</label></th>
248 <td align="left"><input type="checkbox" name="<?php echo OPTION_RSVP_PASSCODE; ?>" id="<?php echo OPTION_RSVP_PASSCODE; ?>" value="Y"
249 <?php echo ((get_option(OPTION_RSVP_PASSCODE) == "Y") ? " checked=\"checked\"" : ""); ?> /></td>
250 </tr>
251 <tr valign="top">
252 <th scope="row"><label for="rsvp_debug_queries">Debug RSVP Queries:</label></th>
253 <td align="left"><input type="checkbox" name="rsvp_debug_queries" id="rsvp_debug_queries"
254 value="Y" <?php echo ((get_option(OPTION_DEBUG_RSVP_QUERIES) == "Y") ? " checked=\"checked\"" : ""); ?> /></td>
255 </tr>
256 </table>
257 <input type="hidden" name="action" value="update" />
258 <p class="submit">
259 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
260 </p>
261 </form>
262 </div>
263 <?php
264 }
265
266 function rsvp_admin_guestlist() {
267 global $wpdb;
268
269 if(get_option("rsvp_db_version") != RSVP_DB_VERSION) {
270 rsvp_database_setup();
271 }
272 rsvp_install_passcode_field();
273 if((count($_POST) > 0) && ($_POST['rsvp-bulk-action'] == "delete") && (is_array($_POST['attendee']) && (count($_POST['attendee']) > 0))) {
274 foreach($_POST['attendee'] as $attendee) {
275 if(is_numeric($attendee) && ($attendee > 0)) {
276 $wpdb->query($wpdb->prepare("DELETE FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d OR associatedAttendeeID = %d",
277 $attendee,
278 $attendee));
279 $wpdb->query($wpdb->prepare("DELETE FROM ".ATTENDEES_TABLE." WHERE id = %d",
280 $attendee));
281 }
282 }
283 }
284
285 $sql = "SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal, personalGreeting, passcode FROM ".ATTENDEES_TABLE;
286 $orderBy = " lastName, firstName";
287 if(isset($_GET['sort'])) {
288 if(strToLower($_GET['sort']) == "rsvpstatus") {
289 $orderBy = " rsvpStatus ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
290 }else if(strToLower($_GET['sort']) == "attendee") {
291 $direction = ((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC");
292 $orderBy = " lastName $direction, firstName $direction";
293 } else if(strToLower($_GET['sort']) == "kidsmeal") {
294 $orderBy = " kidsMeal ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
295 } else if(strToLower($_GET['sort']) == "additional") {
296 $orderBy = " additionalAttendee ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
297 } else if(strToLower($_GET['sort']) == "vegetarian") {
298 $orderBy = " veggieMeal ".((strtolower($_GET['sortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
299 }
300 }
301 $sql .= " ORDER BY ".$orderBy;
302 $attendees = $wpdb->get_results($sql);
303 $sort = "";
304 $sortDirection = "asc";
305 if(isset($_GET['sort'])) {
306 $sort = $_GET['sort'];
307 }
308
309 if(isset($_GET['sortDirection'])) {
310 $sortDirection = $_GET['sortDirection'];
311 }
312 ?>
313 <script type="text/javascript" language="javascript">
314 jQuery(document).ready(function() {
315 jQuery("#cb").click(function() {
316 if(jQuery("#cb").attr("checked")) {
317 jQuery("input[name='attendee[]']").attr("checked", "checked");
318 } else {
319 jQuery("input[name='attendee[]']").removeAttr("checked");
320 }
321 });
322 });
323 </script>
324 <div class="wrap">
325 <div id="icon-edit" class="icon32"><br /></div>
326 <h2>List of current attendees</h2>
327 <form method="post" id="rsvp-form" enctype="multipart/form-data">
328 <input type="hidden" id="rsvp-bulk-action" name="rsvp-bulk-action" />
329 <input type="hidden" id="sortValue" name="sortValue" value="<?php echo htmlentities($sort, ENT_QUOTES); ?>" />
330 <input type="hidden" name="exportSortDirection" value="<?php echo htmlentities($sortDirection, ENT_QUOTES); ?>" />
331 <div class="tablenav">
332 <div class="alignleft actions">
333 <select id="rsvp-action-top" name="action">
334 <option value="" selected="selected"><?php _e('Bulk Actions', 'rsvp'); ?></option>
335 <option value="delete"><?php _e('Delete', 'rsvp'); ?></option>
336 </select>
337 <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;" />
338 <input type="submit" value="<?php _e('Export Attendees', 'rsvp'); ?>" name="exportButton" id="exportButton" class="button-secondary action" onclick="document.getElementById('rsvp-bulk-action').value = 'export';" />
339 </div>
340 <?php
341 $yesResults = $wpdb->get_results("SELECT COUNT(*) AS yesCount FROM ".ATTENDEES_TABLE." WHERE rsvpStatus = 'Yes'");
342 $noResults = $wpdb->get_results("SELECT COUNT(*) AS noCount FROM ".ATTENDEES_TABLE." WHERE rsvpStatus = 'No'");
343 $noResponseResults = $wpdb->get_results("SELECT COUNT(*) AS noResponseCount FROM ".ATTENDEES_TABLE." WHERE rsvpStatus = 'NoResponse'");
344 $kidsMeals = $wpdb->get_results("SELECT COUNT(*) AS kidsMealCount FROM ".ATTENDEES_TABLE." WHERE kidsMeal = 'Y'");
345 $veggieMeals = $wpdb->get_results("SELECT COUNT(*) AS veggieMealCount FROM ".ATTENDEES_TABLE." WHERE veggieMeal = 'Y'");
346 ?>
347 <div class="alignright">RSVP Count -
348 Yes: <strong><?php echo $yesResults[0]->yesCount; ?></strong> &nbsp; &nbsp; &nbsp; &nbsp;
349 No: <strong><?php echo $noResults[0]->noCount; ?></strong> &nbsp; &nbsp; &nbsp; &nbsp;
350 No Response: <strong><?php echo $noResponseResults[0]->noResponseCount; ?></strong> &nbsp; &nbsp; &nbsp; &nbsp;
351 Kids Meals: <strong><?php echo $kidsMeals[0]->kidsMealCount; ?></strong> &nbsp; &nbsp; &nbsp; &nbsp;
352 Veggie Meals: <strong><?php echo $veggieMeals[0]->veggieMealCount; ?></strong>
353 </div>
354 <div class="clear"></div>
355 </div>
356 <table class="widefat post fixed" cellspacing="0">
357 <thead>
358 <tr>
359 <th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" id="cb" /></th>
360 <th scope="col" id="attendeeName" class="manage-column column-title" style="">Attendee</a> &nbsp;
361 <a href="admin.php?page=rsvp-top-level&amp;sort=attendee&amp;sortDirection=asc">
362 <img src="<?php echo plugins_url(); ?>/rsvp/uparrow<?php
363 echo ((($sort == "attendee") && ($sortDirection == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
364 alt="Sort Ascending Attendee Status" title="Sort Ascending Attendee Status" border="0"></a> &nbsp;
365 <a href="admin.php?page=rsvp-top-level&amp;sort=attendee&amp;sortDirection=desc">
366 <img src="<?php echo plugins_url(); ?>/rsvp/downarrow<?php
367 echo ((($sort == "attendee") && ($sortDirection == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
368 alt="Sort Descending Attendee Status" title="Sort Descending Attendee Status" border="0"></a>
369 </th>
370 <th scope="col" id="rsvpStatus" class="manage-column column-title" style="">RSVP Status &nbsp;
371 <a href="admin.php?page=rsvp-top-level&amp;sort=rsvpStatus&amp;sortDirection=asc">
372 <img src="<?php echo plugins_url(); ?>/rsvp/uparrow<?php
373 echo ((($sort == "rsvpStatus") && ($sortDirection == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
374 alt="Sort Ascending RSVP Status" title="Sort Ascending RSVP Status" border="0"></a> &nbsp;
375 <a href="admin.php?page=rsvp-top-level&amp;sort=rsvpStatus&amp;sortDirection=desc">
376 <img src="<?php echo plugins_url(); ?>/rsvp/downarrow<?php
377 echo ((($sort == "rsvpStatus") && ($sortDirection == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
378 alt="Sort Descending RSVP Status" title="Sort Descending RSVP Status" border="0"></a>
379 </th>
380 <?php if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {?>
381 <th scope="col" id="kidsMeal" class="manage-column column-title" style="">Kids Meal &nbsp;
382 <a href="admin.php?page=rsvp-top-level&amp;sort=kidsMeal&amp;sortDirection=asc">
383 <img src="<?php echo plugins_url(); ?>/rsvp/uparrow<?php
384 echo ((($sort == "kidsMeal") && ($sortDirection == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
385 alt="Sort Ascending Kids Meal Status" title="Sort Ascending Kids Meal Status" border="0"></a> &nbsp;
386 <a href="admin.php?page=rsvp-top-level&amp;sort=kidsMeal&amp;sortDirection=desc">
387 <img src="<?php echo plugins_url(); ?>/rsvp/downarrow<?php
388 echo ((($sort == "kidsMeal") && ($sortDirection == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
389 alt="Sort Descending Kids Meal Status" title="Sort Descending Kids Meal Status" border="0"></a>
390 </th>
391 <?php } ?>
392 <th scope="col" id="additionalAttendee" class="manage-column column-title" style="">Additional Attendee &nbsp;
393 <a href="admin.php?page=rsvp-top-level&amp;sort=additional&amp;sortDirection=asc">
394 <img src="<?php echo plugins_url(); ?>/rsvp/uparrow<?php
395 echo ((($sort == "additional") && ($sortDirection == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
396 alt="Sort Ascending Additional Attendees Status" title="Sort Ascending Additional Attendees Status" border="0"></a> &nbsp;
397 <a href="admin.php?page=rsvp-top-level&amp;sort=additional&amp;sortDirection=desc">
398 <img src="<?php echo plugins_url(); ?>/rsvp/downarrow<?php
399 echo ((($sort == "additional") && ($sortDirection == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
400 alt="Sort Descending Additional Attendees Status" title="Sort Descending Additional Atttendees Status" border="0"></a>
401 </th>
402 <?php if(get_option(OPTION_HIDE_VEGGIE) != "Y") {?>
403 <th scope="col" id="veggieMeal" class="manage-column column-title" style="">Vegetarian &nbsp;
404 <a href="admin.php?page=rsvp-top-level&amp;sort=vegetarian&amp;sortDirection=asc">
405 <img src="<?php echo plugins_url(); ?>/rsvp/uparrow<?php
406 echo ((($sort == "vegetarian") && ($sortDirection == "asc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
407 alt="Sort Ascending Vegetarian Status" title="Sort Ascending Vegetarian Status" border="0"></a> &nbsp;
408 <a href="admin.php?page=rsvp-top-level&amp;sort=vegetarian&amp;sortDirection=desc">
409 <img src="<?php echo plugins_url(); ?>/rsvp/downarrow<?php
410 echo ((($sort == "vegetarian") && ($sortDirection == "desc")) ? "_selected" : ""); ?>.gif" width="11" height="9"
411 alt="Sort Descending Vegetarian Status" title="Sort Descending Vegetarian Status" border="0"></a>
412 </th>
413 <?php } ?>
414 <th scope="col" id="customMessage" class="manage-column column-title" style="">Custom Message</th>
415 <th scope="col" id="note" class="manage-column column-title" style="">Note</th>
416 <?php
417 if(get_option(OPTION_RSVP_PASSCODE) == "Y") {
418 ?>
419 <th scope="col" id="passcode" class="manage-column column-title" style="">Passcode</th>
420 <?php
421 }
422
423 ?>
424 <?php
425 $qRs = $wpdb->get_results("SELECT id, question FROM ".QUESTIONS_TABLE." ORDER BY sortOrder, id");
426 if(count($qRs) > 0) {
427 foreach($qRs as $q) {
428 ?>
429 <th scope="col" class="manage-column -column-title"><?php echo htmlentities(stripslashes($q->question)); ?></th>
430 <?php
431 }
432 }
433 ?>
434 <th scope="col" id="associatedAttendees" class="manage-column column-title" style="">Associated Attendees</th>
435 </tr>
436 </thead>
437 </table>
438 <div style="overflow: auto;height: 450px;">
439 <table class="widefat post fixed" cellspacing="0">
440 <?php
441 $i = 0;
442 foreach($attendees as $attendee) {
443 ?>
444 <tr class="<?php echo (($i % 2 == 0) ? "alternate" : ""); ?> author-self">
445 <th scope="row" class="check-column"><input type="checkbox" name="attendee[]" value="<?php echo $attendee->id; ?>" /></th>
446 <td>
447 <a href="<?php echo get_option("siteurl"); ?>/wp-admin/admin.php?page=rsvp-admin-guest&amp;id=<?php echo $attendee->id; ?>"><?php echo htmlentities(stripslashes($attendee->firstName)." ".stripslashes($attendee->lastName)); ?></a>
448 </td>
449 <td><?php echo $attendee->rsvpStatus; ?></td>
450 <?php if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {?>
451 <td><?php
452 if($attendee->rsvpStatus == "NoResponse") {
453 echo "--";
454 } else {
455 echo (($attendee->kidsMeal == "Y") ? "Yes" : "No");
456 }?></td>
457 <?php } ?>
458 <td><?php
459 if($attendee->rsvpStatus == "NoResponse") {
460 echo "--";
461 } else {
462 echo (($attendee->additionalAttendee == "Y") ? "Yes" : "No");
463 }
464 ?></td>
465 <?php if(get_option(OPTION_HIDE_VEGGIE) != "Y") {?>
466 <td><?php
467 if($attendee->rsvpStatus == "NoResponse") {
468 echo "--";
469 } else {
470 echo (($attendee->veggieMeal == "Y") ? "Yes" : "No");
471 }
472 ?></td>
473 <?php } ?>
474 <td><?php
475 echo nl2br(stripslashes(trim($attendee->personalGreeting)));
476 ?></td>
477 <td><?php echo nl2br(stripslashes(trim($attendee->note))); ?></td>
478 <?php
479 if(get_option(OPTION_RSVP_PASSCODE) == "Y") {
480 ?>
481 <td><?php echo $attendee->passcode; ?></td>
482 <?php
483 }
484 $sql = "SELECT question, answer FROM ".QUESTIONS_TABLE." q
485 LEFT JOIN ".ATTENDEE_ANSWERS." ans ON q.id = ans.questionID AND ans.attendeeID = %d
486 ORDER BY q.sortOrder";
487 $aRs = $wpdb->get_results($wpdb->prepare($sql, $attendee->id));
488 if(count($aRs) > 0) {
489 foreach($aRs as $a) {
490 ?>
491 <td><?php echo htmlentities(stripslashes($a->answer)); ?></td>
492 <?php
493 }
494 }
495 ?>
496 <td>
497 <?php
498 $sql = "SELECT firstName, lastName FROM ".ATTENDEES_TABLE."
499 WHERE id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d)
500 OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)";
501
502 $associations = $wpdb->get_results($wpdb->prepare($sql, $attendee->id, $attendee->id));
503 foreach($associations as $a) {
504 echo htmlentities(stripslashes($a->firstName." ".$a->lastName))."<br />";
505 }
506 ?>
507 </td>
508 </tr>
509 <?php
510 $i++;
511 }
512 ?>
513 </table>
514 </div>
515 </form>
516 </div>
517 <?php
518 }
519
520 function rsvp_admin_export() {
521 global $wpdb;
522 $sql = "SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal
523 FROM ".ATTENDEES_TABLE;
524
525 $orderBy = " lastName, firstName";
526 if(isset($_POST['sortValue'])) {
527 if(strToLower($_POST['sortValue']) == "rsvpstatus") {
528 $orderBy = " rsvpStatus ".((strtolower($_POST['exportSortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
529 }else if(strToLower($_POST['sortValue']) == "attendee") {
530 $direction = ((strtolower($_POST['exportSortDirection']) == "desc") ? "DESC" : "ASC");
531 $orderBy = " lastName $direction, firstName $direction";
532 } else if(strToLower($_POST['sortValue']) == "kidsmeal") {
533 $orderBy = " kidsMeal ".((strtolower($_POST['exportSortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
534 } else if(strToLower($_POST['sortValue']) == "additional") {
535 $orderBy = " additionalAttendee ".((strtolower($_POST['exportSortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
536 } else if(strToLower($_POST['sortValue']) == "vegetarian") {
537 $orderBy = " veggieMeal ".((strtolower($_POST['exportSortDirection']) == "desc") ? "DESC" : "ASC") .", ".$orderBy;
538 }
539 }
540 $sql .= " ORDER BY ".$orderBy;
541 $attendees = $wpdb->get_results($sql);
542 $csv = "\"Attendee\",\"RSVP Status\",";
543
544 if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
545 $csv .= "\"Kids Meal\",";
546 }
547 $csv .= "\"Additional Attendee\",";
548
549 if(get_option(OPTION_HIDE_VEGGIE) != "Y") {
550 $csv .= "\"Vegatarian\",";
551 }
552 $csv .= "\"Note\",\"Associated Attendees\"";
553
554 $qRs = $wpdb->get_results("SELECT id, question FROM ".QUESTIONS_TABLE." ORDER BY sortOrder, id");
555 if(count($qRs) > 0) {
556 foreach($qRs as $q) {
557 $csv .= ",\"".stripslashes($q->question)."\"";
558 }
559 }
560
561 $csv .= "\r\n";
562 foreach($attendees as $a) {
563 $csv .= "\"".stripslashes($a->firstName." ".$a->lastName)."\",\"".($a->rsvpStatus)."\",";
564
565 if(get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
566 $csv .= "\"".(($a->kidsMeal == "Y") ? "Yes" : "No")."\",";
567 }
568
569 $csv .= "\"".(($a->additionalAttendee == "Y") ? "Yes" : "No")."\",";
570
571 if(get_option(OPTION_HIDE_VEGGIE) != "Y") {
572 $csv .= "\"".(($a->veggieMeal == "Y") ? "Yes" : "No")."\",";
573 }
574
575 $csv .= "\"".(str_replace("\"", "\"\"", stripslashes($a->note)))."\",\"";
576
577 $sql = "SELECT firstName, lastName FROM ".ATTENDEES_TABLE."
578 WHERE id IN (SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = %d)
579 OR id in (SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeID = %d)";
580
581 $associations = $wpdb->get_results($wpdb->prepare($sql, $a->id, $a->id));
582 foreach($associations as $assc) {
583 $csv .= trim(stripslashes($assc->firstName." ".$assc->lastName))."\r\n";
584 }
585 $csv .= "\"";
586
587 $qRs = $wpdb->get_results("SELECT id, question FROM ".QUESTIONS_TABLE." ORDER BY sortOrder, id");
588 if(count($qRs) > 0) {
589 foreach($qRs as $q) {
590 $aRs = $wpdb->get_results($wpdb->prepare("SELECT answer FROM ".ATTENDEE_ANSWERS." WHERE attendeeID = %d AND questionID = %d", $a->id, $q->id));
591 if(count($aRs) > 0) {
592 $csv .= ",\"".stripslashes($aRs[0]->answer)."\"";
593 } else {
594 $csv .= ",\"\"";
595 }
596 }
597 }
598
599 $csv .= "\r\n";
600 }
601 if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {
602 // IE Bug in download name workaround
603 ini_set( 'zlib.output_compression','Off' );
604 }
605 header('Content-Description: RSVP Export');
606 header("Content-Type: application/vnd.ms-excel", true);
607 header('Content-Disposition: attachment; filename="rsvpEntries.csv"');
608 echo $csv;
609 exit();
610 }
611
612 function rsvp_admin_import() {
613 global $wpdb;
614 if(count($_FILES) > 0) {
615 check_admin_referer('rsvp-import');
616 require_once("Excel/reader.php");
617 $data = new Spreadsheet_Excel_Reader();
618 $data->read($_FILES['importFile']['tmp_name']);
619 if($data->sheets[0]['numCols'] >= 2) {
620 $count = 0;
621 for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
622 $fName = trim($data->sheets[0]['cells'][$i][1]);
623 $lName = trim($data->sheets[0]['cells'][$i][2]);
624 $personalGreeting = (isset($data->sheets[0]['cells'][$i][4])) ? $personalGreeting = $data->sheets[0]['cells'][$i][4] : "";
625 if(!empty($fName) && !empty($lName)) {
626 $sql = "SELECT id FROM ".ATTENDEES_TABLE."
627 WHERE firstName = %s AND lastName = %s ";
628 $res = $wpdb->get_results($wpdb->prepare($sql, $fName, $lName));
629 if(count($res) == 0) {
630 $wpdb->insert(ATTENDEES_TABLE, array("firstName" => $fName,
631 "lastName" => $lName,
632 "personalGreeting" => $personalGreeting),
633 array('%s', '%s', '%s'));
634 $count++;
635 }
636 }
637 }
638
639 if($data->sheets[0]['numCols'] >= 3) {
640 // There must be associated users so let's associate them
641 for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
642 $fName = trim($data->sheets[0]['cells'][$i][1]);
643 $lName = trim($data->sheets[0]['cells'][$i][2]);
644 if(!empty($fName) && !empty($lName) && (count($data->sheets[0]['cells'][$i]) >= 3)) {
645 // Get the user's id
646 $sql = "SELECT id FROM ".ATTENDEES_TABLE."
647 WHERE firstName = %s AND lastName = %s ";
648 $res = $wpdb->get_results($wpdb->prepare($sql, $fName, $lName));
649 if((count($res) > 0) && isset($data->sheets[0]['cells'][$i][3])) {
650 $userId = $res[0]->id;
651
652 // Deal with the assocaited users...
653 $associatedUsers = explode(",", trim($data->sheets[0]['cells'][$i][3]));
654 if(is_array($associatedUsers)) {
655 foreach($associatedUsers as $au) {
656 $user = explode(" ", trim($au), 2);
657 // Three cases, they didn't enter in all of the information, user exists or doesn't.
658 // If user exists associate the two users
659 // If user does not exist add the user and then associate the two
660 if(is_array($user) && (count($user) == 2)) {
661 $sql = "SELECT id FROM ".ATTENDEES_TABLE."
662 WHERE firstName = %s AND lastName = %s ";
663 $userRes = $wpdb->get_results($wpdb->prepare($sql, trim($user[0]), trim($user[1])));
664 if(count($userRes) > 0) {
665 $newUserId = $userRes[0]->id;
666 } else {
667 // Insert them and then we can associate them...
668 $wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($user[0]), "lastName" => trim($user[1])), array('%s', '%s'));
669 $newUserId = $wpdb->insert_id;
670 $count++;
671 }
672
673 $wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID" => $newUserId,
674 "associatedAttendeeID" => $userId),
675 array("%d", "%d"));
676
677 $wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID" => $userId,
678 "associatedAttendeeID" => $newUserId),
679 array("%d", "%d"));
680 }
681 }
682 }
683 }
684 }
685 }
686 }
687 ?>
688 <p><strong><?php echo $count; ?></strong> total records were imported.</p>
689 <p>Continue to the RSVP <a href="admin.php?page=rsvp-top-level">list</a></p>
690 <?php
691 }
692 } else {
693 ?>
694 <form name="rsvp_import" method="post" enctype="multipart/form-data">
695 <?php wp_nonce_field('rsvp-import'); ?>
696 <p>Select an excel file (only xls please, xlsx is not supported....yet) in the following format:<br />
697 <strong>First Name</strong> | <strong>Last Name</strong> | <strong>Associated Attendees*</strong> | <strong>Custom Message</strong>
698 </p>
699 <p>
700 * associated attendees should be separated by a comma it is assumed that the first space encounted will separate the first and last name.
701 </p>
702 <p>A header row is not expected.</p>
703 <p><input type="file" name="importFile" id="importFile" /></p>
704 <p><input type="submit" value="Import File" name="goRsvp" /></p>
705 </form>
706 <?php
707 }
708 }
709
710 function rsvp_admin_guest() {
711 global $wpdb;
712 if((count($_POST) > 0) && !empty($_POST['firstName']) && !empty($_POST['lastName'])) {
713 check_admin_referer('rsvp_add_guest');
714 $passcode = (isset($_POST['passcode'])) ? $_POST['passcode'] : "";
715
716 if(isset($_SESSION[EDIT_SESSION_KEY]) && is_numeric($_SESSION[EDIT_SESSION_KEY])) {
717 $wpdb->update(ATTENDEES_TABLE,
718 array("firstName" => trim($_POST['firstName']),
719 "lastName" => trim($_POST['lastName']),
720 "personalGreeting" => trim($_POST['personalGreeting']),
721 "rsvpStatus" => trim($_POST['rsvpStatus'])),
722 array("id" => $_SESSION[EDIT_SESSION_KEY]),
723 array("%s", "%s", "%s", "%s"),
724 array("%d"));
725 rsvp_printQueryDebugInfo();
726 $attendeeId = $_SESSION[EDIT_SESSION_KEY];
727 $wpdb->query($wpdb->prepare("DELETE FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeId = %d", $attendeeId));
728 } else {
729 $wpdb->insert(ATTENDEES_TABLE, array("firstName" => trim($_POST['firstName']),
730 "lastName" => trim($_POST['lastName']),
731 "personalGreeting" => trim($_POST['personalGreeting']),
732 "rsvpStatus" => trim($_POST['rsvpStatus'])),
733 array('%s', '%s', '%s', '%s'));
734 rsvp_printQueryDebugInfo();
735
736 $attendeeId = $wpdb->insert_id;
737 }
738
739 if(isset($_POST['associatedAttendees']) && is_array($_POST['associatedAttendees'])) {
740 foreach($_POST['associatedAttendees'] as $aid) {
741 if(is_numeric($aid) && ($aid > 0)) {
742 $wpdb->insert(ASSOCIATED_ATTENDEES_TABLE, array("attendeeID"=>$attendeeId, "associatedAttendeeID"=>$aid), array("%d", "%d"));
743 rsvp_printQueryDebugInfo();
744 }
745 }
746 }
747
748 if(get_option(OPTION_RSVP_PASSCODE) == "Y") {
749 if(empty($passcode)) {
750 $passcode = rsvp_generate_passcode();
751 }
752 $wpdb->update(ATTENDEES_TABLE,
753 array("passcode" => trim($passcode)),
754 array("id"=>$attendeeId),
755 array("%s"),
756 array("%d"));
757 }
758 ?>
759 <p>Attendee <?php echo htmlentities(stripslashes($_POST['firstName']." ".$_POST['lastName']));?> has been successfully saved</p>
760 <p>
761 <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=rsvp-top-level">Continue to Attendee List</a> |
762 <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=rsvp-admin-guest">Add a Guest</a>
763 </p>
764 <?php
765 } else {
766 $attendee = null;
767 unset($_SESSION[EDIT_SESSION_KEY]);
768 $associatedAttendees = array();
769 $firstName = "";
770 $lastName = "";
771 $personalGreeting = "";
772 $rsvpStatus = "NoResponse";
773 $passcode = "";
774
775 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
776 $attendee = $wpdb->get_row("SELECT id, firstName, lastName, personalGreeting, rsvpStatus, passcode FROM ".ATTENDEES_TABLE." WHERE id = ".$_GET['id']);
777 if($attendee != null) {
778 $_SESSION[EDIT_SESSION_KEY] = $attendee->id;
779 $firstName = stripslashes($attendee->firstName);
780 $lastName = stripslashes($attendee->lastName);
781 $personalGreeting = stripslashes($attendee->personalGreeting);
782 $rsvpStatus = $attendee->rsvpStatus;
783 $passcode = stripslashes($attendee->passcode);
784
785 // Get the associated attendees and add them to an array
786 $associations = $wpdb->get_results("SELECT associatedAttendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE attendeeId = ".$attendee->id.
787 " UNION ".
788 "SELECT attendeeID FROM ".ASSOCIATED_ATTENDEES_TABLE." WHERE associatedAttendeeID = ".$attendee->id);
789 foreach($associations as $aId) {
790 $associatedAttendees[] = $aId->associatedAttendeeID;
791 }
792 }
793 }
794 ?>
795 <form name="contact" action="admin.php?page=rsvp-admin-guest" method="post">
796 <?php wp_nonce_field('rsvp_add_guest'); ?>
797 <p class="submit">
798 <input type="submit" class="button-primary" value="<?php _e('Save'); ?>" />
799 </p>
800 <table class="form-table">
801 <tr valign="top">
802 <th scope="row"><label for="firstName">First Name:</label></th>
803 <td align="left"><input type="text" name="firstName" id="firstName" size="30" value="<?php echo htmlentities($firstName); ?>" /></td>
804 </tr>
805 <tr valign="top">
806 <th scope="row"><label for="lastName">Last Name:</label></th>
807 <td align="left"><input type="text" name="lastName" id="lastName" size="30" value="<?php echo htmlentities($lastName); ?>" /></td>
808 </tr>
809 <?php
810 if(get_option(OPTION_RSVP_PASSCODE) == "Y") {
811 ?>
812 <tr valign="top">
813 <th scope="row"><label for="passcode">Passcode:</label></th>
814 <td align="left"><input type="text" name="passcode" id="passcode" size="30" value="<?php echo htmlentities($passcode); ?>" maxlength="6" /></td>
815 </tr>
816 <?php
817 }
818 ?>
819 <tr>
820 <th scope="row"><label for="rsvpStatus">RSVP Status</label></th>
821 <td align="left">
822 <select name="rsvpStatus" id="rsvpStatus" size="1">
823 <option value="NoResponse" <?php
824 echo (($rsvpStatus == "NoResponse") ? " selected=\"selected\"" : "");
825 ?>>No Response</option>
826 <option value="Yes" <?php
827 echo (($rsvpStatus == "Yes") ? " selected=\"selected\"" : "");
828 ?>>Yes</option>
829 <option value="No" <?php
830 echo (($rsvpStatus == "No") ? " selected=\"selected\"" : "");
831 ?>>No</option>
832 </select>
833 </td>
834 </tr>
835 <tr valign="top">
836 <th scope="row" valign="top"><label for="personalGreeting">Custom Message:</label></th>
837 <td align="left"><textarea name="personalGreeting" id="personalGreeting" rows="5" cols="40"><?php echo htmlentities($personalGreeting); ?></textarea></td>
838 </tr>
839 <tr valign="top">
840 <th scope="row">Associated Attendees:</th>
841 <td align="left">
842 <select name="associatedAttendees[]" multiple="multiple" size="5" style="height: 200px;">
843 <?php
844 $attendees = $wpdb->get_results("SELECT id, firstName, lastName FROM ".$wpdb->prefix."attendees ORDER BY lastName, firstName");
845 foreach($attendees as $a) {
846 if($a->id != $_SESSION[EDIT_SESSION_KEY]) {
847 ?>
848 <option value="<?php echo $a->id; ?>"
849 <?php echo ((in_array($a->id, $associatedAttendees)) ? "selected=\"selected\"" : ""); ?>><?php echo htmlentities(stripslashes($a->firstName)." ".stripslashes($a->lastName)); ?></option>
850 <?php
851 }
852 }
853 ?>
854 </select>
855 </td>
856 </tr>
857 <?php
858 if(($attendee != null) && ($attendee->id > 0)) {
859 $sql = "SELECT question, answer FROM ".ATTENDEE_ANSWERS." ans
860 INNER JOIN ".QUESTIONS_TABLE." q ON q.id = ans.questionID
861 WHERE attendeeID = %d
862 ORDER BY q.sortOrder";
863 $aRs = $wpdb->get_results($wpdb->prepare($sql, $attendee->id));
864 if(count($aRs) > 0) {
865 ?>
866 <tr>
867 <td colspan="2">
868 <h4>Custom Questions Answered</h4>
869 <table cellpadding="2" cellspacing="0" border="0">
870 <tr>
871 <th>Question</th>
872 <th>Answer</th>
873 </tr>
874 <?php
875 foreach($aRs as $a) {
876 ?>
877 <tr>
878 <td><?php echo stripslashes($a->question); ?></td>
879 <td><?php echo stripslashes($a->answer); ?></td>
880 </tr>
881 <?php
882 }
883 ?>
884 </table>
885 </td>
886 </tr>
887 <?php
888 }
889 }
890 ?>
891 </table>
892 <p class="submit">
893 <input type="submit" class="button-primary" value="<?php _e('Save'); ?>" />
894 </p>
895 </form>
896 <?php
897 }
898 }
899
900 function rsvp_admin_questions() {
901 global $wpdb;
902
903 if((count($_POST) > 0) && ($_POST['rsvp-bulk-action'] == "delete") && (is_array($_POST['q']) && (count($_POST['q']) > 0))) {
904 foreach($_POST['q'] as $q) {
905 if(is_numeric($q) && ($q > 0)) {
906 $wpdb->query($wpdb->prepare("DELETE FROM ".QUESTIONS_TABLE." WHERE id = %d", $q));
907 $wpdb->query($wpdb->prepare("DELETE FROM ".ATTENDEE_ANSWERS." WHERE questionID = %d", $q));
908 }
909 }
910 } else if((count($_POST) > 0) && ($_POST['rsvp-bulk-action'] == "saveSortOrder")) {
911 $sql = "SELECT id FROM ".QUESTIONS_TABLE;
912 $sortQs = $wpdb->get_results($sql);
913 foreach($sortQs as $q) {
914 if(is_numeric($_POST['sortOrder'.$q->id]) && ($_POST['sortOrder'.$q->id] >= 0)) {
915 $wpdb->update(QUESTIONS_TABLE,
916 array("sortOrder" => $_POST['sortOrder'.$q->id]),
917 array("id" => $q->id),
918 array("%d"),
919 array("%d"));
920 rsvp_printQueryDebugInfo();
921 }
922 }
923 }
924
925 $sql = "SELECT id, question, sortOrder FROM ".QUESTIONS_TABLE." ORDER BY sortOrder ASC";
926 $customQs = $wpdb->get_results($sql);
927 ?>
928 <script type="text/javascript" language="javascript">
929 jQuery(document).ready(function() {
930 jQuery("#cb").click(function() {
931 if(jQuery("#cb").attr("checked")) {
932 jQuery("input[name='q[]']").attr("checked", "checked");
933 } else {
934 jQuery("input[name='q[]']").removeAttr("checked");
935 }
936 });
937
938 jQuery("#customQuestions").tableDnD({
939 onDrop: function(table, row) {
940 var rows = table.tBodies[0].rows;
941 for (var i=0; i<rows.length; i++) {
942 jQuery("#sortOrder" + rows[i].id).val(i);
943 }
944
945 }
946 });
947 });
948 </script>
949 <div class="wrap">
950 <div id="icon-edit" class="icon32"><br /></div>
951 <h2>List of current custom questions</h2>
952 <form method="post" id="rsvp-form" enctype="multipart/form-data">
953 <input type="hidden" id="rsvp-bulk-action" name="rsvp-bulk-action" />
954 <div class="tablenav">
955 <div class="alignleft actions">
956 <select id="rsvp-action-top" name="action">
957 <option value="" selected="selected"><?php _e('Bulk Actions', 'rsvp'); ?></option>
958 <option value="delete"><?php _e('Delete', 'rsvp'); ?></option>
959 </select>
960 <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;" />
961 <input type="submit" value="<?php _e('Save Sort Order', 'rsvp'); ?>" name="saveSortButton" id="saveSortButton" class="button-secondary action" onclick="document.getElementById('rsvp-bulk-action').value = 'saveSortOrder';" />
962 </div>
963 <div class="clear"></div>
964 </div>
965 <table class="widefat post fixed" cellspacing="0">
966 <thead>
967 <tr>
968 <th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" id="cb" /></th>
969 <th scope="col" id="questionCol" class="manage-column column-title" style="">Question</th>
970 </tr>
971 </thead>
972 </table>
973 <div style="overflow: auto;height: 450px;">
974 <table class="widefat post fixed" cellspacing="0" id="customQuestions">
975 <?php
976 $i = 0;
977 foreach($customQs as $q) {
978 ?>
979 <tr class="<?php echo (($i % 2 == 0) ? "alternate" : ""); ?> author-self" id="<?php echo $q->id; ?>">
980 <th scope="row" class="check-column"><input type="checkbox" name="q[]" value="<?php echo $q->id; ?>" /></th>
981 <td>
982 <a href="<?php echo get_option("siteurl"); ?>/wp-admin/admin.php?page=rsvp-admin-custom-question&amp;id=<?php echo $q->id; ?>"><?php echo htmlentities(stripslashes($q->question)); ?></a>
983 <input type="hidden" name="sortOrder<?php echo $q->id; ?>" id="sortOrder<?php echo $q->id; ?>" value="<?php echo $q->sortOrder; ?>" />
984 </td>
985 </tr>
986 <?php
987 $i++;
988 }
989 ?>
990 </table>
991 </div>
992 </form>
993 </div>
994 <?php
995 }
996
997 function rsvp_admin_custom_question() {
998 global $wpdb;
999 $answerQuestionTypes = array(2,4,5);
1000
1001 $radioQuestionType = $wpdb->get_results("SELECT id FROM ".QUESTION_TYPE_TABLE." WHERE questionType = 'radio'");
1002 if($radioQuestionType == 0) {
1003 $wpdb->insert(QUESTION_TYPE_TABLE, array("questionType" => "radio", "friendlyName" => "Radio"), array('%s', '%s'));
1004 rsvp_printQueryDebugInfo();
1005 }
1006
1007 if((count($_POST) > 0) && !empty($_POST['question']) && is_numeric($_POST['questionTypeID'])) {
1008 check_admin_referer('rsvp_add_custom_question');
1009 if(isset($_SESSION[EDIT_QUESTION_KEY]) && is_numeric($_SESSION[EDIT_QUESTION_KEY])) {
1010 $wpdb->update(QUESTIONS_TABLE,
1011 array("question" => trim($_POST['question']),
1012 "questionTypeID" => trim($_POST['questionTypeID']),
1013 "permissionLevel" => ((trim($_POST['permissionLevel']) == "private") ? "private" : "public")),
1014 array("id" => $_SESSION[EDIT_QUESTION_KEY]),
1015 array("%s", "%d", "%s"),
1016 array("%d"));
1017 rsvp_printQueryDebugInfo();
1018 $questionId = $_SESSION[EDIT_QUESTION_KEY];
1019
1020 $answers = $wpdb->get_results($wpdb->prepare("SELECT id FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $questionId));
1021 if(count($answers) > 0) {
1022 foreach($answers as $a) {
1023 if(isset($_POST['deleteAnswer'.$a->id]) && (strToUpper($_POST['deleteAnswer'.$a->id]) == "Y")) {
1024 $wpdb->query($wpdb->prepare("DELETE FROM ".QUESTION_ANSWERS_TABLE." WHERE id = %d", $a->id));
1025 } elseif(isset($_POST['answer'.$a->id]) && !empty($_POST['answer'.$a->id])) {
1026 $wpdb->update(QUESTION_ANSWERS_TABLE,
1027 array("answer" => trim($_POST['answer'.$a->id])),
1028 array("id"=>$a->id),
1029 array("%s"),
1030 array("%d"));
1031 rsvp_printQueryDebugInfo();
1032 }
1033 }
1034 }
1035 } else {
1036 $wpdb->insert(QUESTIONS_TABLE, array("question" => trim($_POST['question']),
1037 "questionTypeID" => trim($_POST['questionTypeID']),
1038 "permissionLevel" => ((trim($_POST['permissionLevel']) == "private") ? "private" : "public")),
1039 array('%s', '%d', '%s'));
1040 rsvp_printQueryDebugInfo();
1041 $questionId = $wpdb->insert_id;
1042 }
1043
1044 if(isset($_POST['numNewAnswers']) && is_numeric($_POST['numNewAnswers']) &&
1045 in_array($_POST['questionTypeID'], $answerQuestionTypes)) {
1046 for($i = 0; $i < $_POST['numNewAnswers']; $i++) {
1047 if(isset($_POST['newAnswer'.$i]) && !empty($_POST['newAnswer'.$i])) {
1048 $wpdb->insert(QUESTION_ANSWERS_TABLE, array("questionID"=>$questionId, "answer"=>$_POST['newAnswer'.$i]));
1049 rsvp_printQueryDebugInfo();
1050 }
1051 }
1052 }
1053
1054 if(strToLower(trim($_POST['permissionLevel'])) == "private") {
1055 $wpdb->query($wpdb->prepare("DELETE FROM ".QUESTION_ATTENDEES_TABLE." WHERE questionID = %d", $questionId));
1056 if(isset($_POST['attendees']) && is_array($_POST['attendees'])) {
1057 foreach($_POST['attendees'] as $aid) {
1058 if(is_numeric($aid) && ($aid > 0)) {
1059 $wpdb->insert(QUESTION_ATTENDEES_TABLE, array("attendeeID"=>$aid, "questionID"=>$questionId), array("%d", "%d"));
1060 rsvp_printQueryDebugInfo();
1061 }
1062 }
1063 }
1064 }
1065 ?>
1066 <p>Custom Question saved</p>
1067 <p>
1068 <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=rsvp-admin-questions">Continue to Question List</a> |
1069 <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=rsvp-admin-custom-question">Add another Question</a>
1070 </p>
1071 <?php
1072 } else {
1073 $questionTypeId = 0;
1074 $question = "";
1075 $isNew = true;
1076 $questionId = 0;
1077 $permissionLevel = "public";
1078 $savedAttendees = array();
1079 unset($_SESSION[EDIT_QUESTION_KEY]);
1080 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
1081 $qRs = $wpdb->get_results($wpdb->prepare("SELECT id, question, questionTypeID, permissionLevel FROM ".QUESTIONS_TABLE." WHERE id = %d", $_GET['id']));
1082 if(count($qRs) > 0) {
1083 $isNew = false;
1084 $_SESSION[EDIT_QUESTION_KEY] = $qRs[0]->id;
1085 $questionId = $qRs[0]->id;
1086 $question = stripslashes($qRs[0]->question);
1087 $permissionLevel = stripslashes($qRs[0]->permissionLevel);
1088 $questionTypeId = $qRs[0]->questionTypeID;
1089
1090 if($permissionLevel == "private") {
1091 $aRs = $wpdb->get_results($wpdb->prepare("SELECT attendeeID FROM ".QUESTION_ATTENDEES_TABLE." WHERE questionID = %d", $questionId));
1092 if(count($aRs) > 0) {
1093 foreach($aRs as $a) {
1094 $savedAttendees[] = $a->attendeeID;
1095 }
1096 }
1097 }
1098 }
1099 }
1100
1101 $sql = "SELECT id, questionType, friendlyName FROM ".QUESTION_TYPE_TABLE;
1102 $questionTypes = $wpdb->get_results($sql);
1103 ?>
1104 <script type="text/javascript">
1105 function addAnswer(counterElement) {
1106 var currAnswer = jQuery("#numNewAnswers").val();
1107 if(isNaN(currAnswer)) {
1108 currAnswer = 0;
1109 }
1110
1111 var s = "<tr>\r\n"+
1112 "<td align=\"right\" width=\"75\"><label for=\"newAnswer" + currAnswer + "\">Answer:</label></td>\r\n" +
1113 "<td><input type=\"text\" name=\"newAnswer" + currAnswer + "\" id=\"newAnswer" + currAnswer + "\" size=\"40\" /></td>\r\n" +
1114 "</tr>\r\n";
1115 jQuery("#answerContainer").append(s);
1116 currAnswer++;
1117 jQuery("#numNewAnswers").val(currAnswer);
1118 return false;
1119 }
1120
1121 jQuery(document).ready(function() {
1122
1123 <?php
1124 if($isNew || !in_array($questionTypeId, $answerQuestionTypes)) {
1125 echo 'jQuery("#answerContainer").hide();';
1126 }
1127
1128 if($isNew || ($permissionLevel == "public")) {
1129 ?>
1130 jQuery("#attendeesArea").hide();
1131 <?php
1132 }
1133 ?>
1134 jQuery("#questionType").change(function() {
1135 var selectedValue = jQuery("#questionType").val();
1136 if((selectedValue == 2) || (selectedValue == 4) || (selectedValue == 5)) {
1137 jQuery("#answerContainer").show();
1138 } else {
1139 jQuery("#answerContainer").hide();
1140 }
1141 })
1142
1143 jQuery("#permissionLevel").change(function() {
1144 if(jQuery("#permissionLevel").val() != "public") {
1145 jQuery("#attendeesArea").show();
1146 } else {
1147 jQuery("#attendeesArea").hide();
1148 }
1149 })
1150 });
1151 </script>
1152 <form name="contact" action="admin.php?page=rsvp-admin-custom-question" method="post">
1153 <input type="hidden" name="numNewAnswers" id="numNewAnswers" value="0" />
1154 <?php wp_nonce_field('rsvp_add_custom_question'); ?>
1155 <p class="submit">
1156 <input type="submit" class="button-primary" value="<?php _e('Save'); ?>" />
1157 </p>
1158 <table id="customQuestions" class="form-table">
1159 <tr valign="top">
1160 <th scope="row"><label for="questionType">Question Type:</label></th>
1161 <td align="left"><select name="questionTypeID" id="questionType" size="1">
1162 <?php
1163 foreach($questionTypes as $qt) {
1164 echo "<option value=\"".$qt->id."\" ".(($questionTypeId == $qt->id) ? " selected=\"selected\"" : "").">".$qt->friendlyName."</option>\r\n";
1165 }
1166 ?>
1167 </select>
1168 </td>
1169 </tr>
1170 <tr valign="top">
1171 <th scope="row"><label for="question">Question:</label></th>
1172 <td align="left"><input type="text" name="question" id="question" size="40" value="<?php echo htmlentities($question); ?>" /></td>
1173 </tr>
1174 <tr>
1175 <th scope="row"><label for="permissionLevel">Question Permission Level:</label></th>
1176 <td align="left"><select name="permissionLevel" id="permissionLevel" size="1">
1177 <option value="public" <?php echo ($permissionLevel == "public") ? " selected=\"selected\"" : ""; ?>>Public</option>
1178 <option value="private" <?php echo ($permissionLevel == "private") ? " selected=\"selected\"" : ""; ?>>Private</option>
1179 </select></td>
1180 </tr>
1181 <tr>
1182 <td colspan="2">
1183 <table cellpadding="0" cellspacing="0" border="0" id="answerContainer">
1184 <tr>
1185 <th>Answers</th>
1186 <th align="right"><a href="#" onclick="return addAnswer();">Add new Answer</a></th>
1187 </tr>
1188 <?php
1189 if(!$isNew) {
1190 $aRs = $wpdb->get_results($wpdb->prepare("SELECT id, answer FROM ".QUESTION_ANSWERS_TABLE." WHERE questionID = %d", $questionId));
1191 if(count($aRs) > 0) {
1192 foreach($aRs as $answer) {
1193 ?>
1194 <tr>
1195 <td width="75" align="right"><label for="answer<?php echo $answer->id; ?>">Answer:</label></td>
1196 <td><input type="text" name="answer<?php echo $answer->id; ?>" id="answer<?php echo $answer->id; ?>" size="40" value="<?php echo htmlentities(stripslashes($answer->answer)); ?>" />
1197 &nbsp; <input type="checkbox" name="deleteAnswer<?php echo $answer->id; ?>" id="deleteAnswer<?php echo $answer->id; ?>" value="Y" /><label for="deleteAnswer<?php echo $answer->id; ?>">Delete</label></td>
1198 </tr>
1199 <?php
1200 }
1201 }
1202 }
1203 ?>
1204 </table>
1205 </td>
1206 </tr>
1207 <tr id="attendeesArea">
1208 <th scope="row"><label for="attendees">Attendees allowed to answer this question:</label></th>
1209 <td>
1210 <select name="attendees[]" id="attendees" style="height:75px;" multiple="multiple">
1211 <?php
1212 $attendees = $wpdb->get_results("SELECT id, firstName, lastName FROM ".$wpdb->prefix."attendees ORDER BY lastName, firstName");
1213 foreach($attendees as $a) {
1214 ?>
1215 <option value="<?php echo $a->id; ?>"
1216 <?php echo ((in_array($a->id, $savedAttendees)) ? " selected=\"selected\"" : ""); ?>><?php echo htmlentities(stripslashes($a->firstName)." ".stripslashes($a->lastName)); ?></option>
1217 <?php
1218 }
1219 ?>
1220 </select>
1221 </td>
1222 </tr>
1223 </table>
1224 </form>
1225 <?php
1226 }
1227 }
1228
1229 function rsvp_modify_menu() {
1230
1231 add_options_page('RSVP Options', //page title
1232 'RSVP Options', //subpage title
1233 'manage_options', //access
1234 'rsvp-options', //current file
1235 'rsvp_admin_guestlist_options' //options function above
1236 );
1237 $page = add_menu_page("RSVP Plugin",
1238 "RSVP Plugin",
1239 "publish_posts",
1240 "rsvp-top-level",
1241 "rsvp_admin_guestlist");
1242 add_action('admin_print_scripts-' . $page, 'rsvp_admin_scripts');
1243 $page = add_submenu_page("rsvp-top-level",
1244 "Add Guest",
1245 "Add Guest",
1246 "publish_posts",
1247 "rsvp-admin-guest",
1248 "rsvp_admin_guest");
1249 add_action('admin_print_scripts-' . $page, 'rsvp_admin_scripts');
1250 add_submenu_page("rsvp-top-level",
1251 "RSVP Export",
1252 "RSVP Export",
1253 "publish_posts",
1254 "rsvp-admin-export",
1255 "rsvp_admin_export");
1256 add_submenu_page("rsvp-top-level",
1257 "RSVP Import",
1258 "RSVP Import",
1259 "publish_posts",
1260 "rsvp-admin-import",
1261 "rsvp_admin_import");
1262 $page = add_submenu_page("rsvp-top-level",
1263 "Custom Questions",
1264 "Custom Questions",
1265 "publish_posts",
1266 "rsvp-admin-questions",
1267 "rsvp_admin_questions");
1268 add_action('admin_print_scripts-' . $page, 'rsvp_admin_scripts');
1269 $page = add_submenu_page("rsvp-top-level",
1270 "Add Custom Question",
1271 "Add Custom Question",
1272 "publish_posts",
1273 "rsvp-admin-custom-question",
1274 "rsvp_admin_custom_question");
1275
1276 add_action('admin_print_scripts-' . $page, 'rsvp_admin_scripts');
1277 }
1278
1279 function rsvp_register_settings() {
1280 register_setting('rsvp-option-group', OPTION_OPENDATE);
1281 register_setting('rsvp-option-group', OPTION_GREETING);
1282 register_setting('rsvp-option-group', OPTION_THANKYOU);
1283 register_setting('rsvp-option-group', OPTION_HIDE_VEGGIE);
1284 register_setting('rsvp-option-group', OPTION_HIDE_KIDS_MEAL);
1285 register_setting('rsvp-option-group', OPTION_NOTE_VERBIAGE);
1286 register_setting('rsvp-option-group', OPTION_VEGGIE_MEAL_VERBIAGE);
1287 register_setting('rsvp-option-group', OPTION_KIDS_MEAL_VERBIAGE);
1288 register_setting('rsvp-option-group', OPTION_YES_VERBIAGE);
1289 register_setting('rsvp-option-group', OPTION_NO_VERBIAGE);
1290 register_setting('rsvp-option-group', OPTION_DEADLINE);
1291 register_setting('rsvp-option-group', OPTION_THANKYOU);
1292 register_setting('rsvp-option-group', OPTION_HIDE_ADD_ADDITIONAL);
1293 register_setting('rsvp-option-group', OPTION_NOTIFY_EMAIL);
1294 register_setting('rsvp-option-group', OPTION_NOTIFY_ON_RSVP);
1295 register_setting('rsvp-option-group', OPTION_DEBUG_RSVP_QUERIES);
1296 register_setting('rsvp-option-group', OPTION_WELCOME_TEXT);
1297 register_setting('rsvp-option-group', OPTION_RSVP_QUESTION);
1298 register_setting('rsvp-option-group', OPTION_RSVP_CUSTOM_YES_NO);
1299 register_setting('rsvp-option-group', OPTION_RSVP_PASSCODE);
1300
1301 wp_register_script('jquery_table_sort', plugins_url('jquery.tablednd_0_5.js',__FILE__));
1302 wp_register_script('jquery_ui', rsvp_getHttpProtocol()."://ajax.microsoft.com/ajax/jquery.ui/1.8.5/jquery-ui.js");
1303 wp_register_style('jquery_ui_stylesheet', rsvp_getHttpProtocol()."://ajax.microsoft.com/ajax/jquery.ui/1.8.5/themes/redmond/jquery-ui.css");
1304 }
1305
1306 function rsvp_admin_scripts() {
1307 wp_enqueue_script("jquery_table_sort");
1308 wp_enqueue_script("jquery_ui");
1309 wp_enqueue_style( 'jquery_ui_stylesheet');
1310 }
1311
1312 function rsvp_init() {
1313 wp_register_script('jquery_validate', rsvp_getHttpProtocol()."://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.min.js");
1314 wp_register_script('rsvp_plugin', plugins_url("rsvp_plugin.js", RSVP_PLUGIN_FILE));
1315 wp_register_style('rsvp_css', plugins_url("rsvp_plugin.css", RSVP_PLUGIN_FILE));
1316 wp_enqueue_script('jquery');
1317 wp_enqueue_script('jquery_validate');
1318 wp_enqueue_script('rsvp_plugin');
1319 wp_enqueue_style("rsvp_css");
1320
1321
1322 load_plugin_textdomain('rsvp-plugin', false, basename( dirname( __FILE__ ) ) . '/languages' );
1323 }
1324
1325 function rsvp_printQueryDebugInfo() {
1326 global $wpdb;
1327
1328 if(get_option(OPTION_DEBUG_RSVP_QUERIES) == "Y") {
1329 echo "<br />Sql Output: ";
1330 $wpdb->print_error();
1331 echo "<br />";
1332 }
1333 }
1334
1335 /*
1336 This function checks to see if the page is running over SSL/HTTPs and will return the proper HTTP protocol.
1337
1338 Postcondition: The caller will receive the proper HTTP protocol to use at the beginning of a URL.
1339 */
1340 function rsvp_getHttpProtocol() {
1341 if(isset($_SERVER['HTTPS']) && (trim($_SERVER['HTTPS']) != "")) {
1342 return "https";
1343 }
1344 return "http";
1345 }
1346
1347 add_action('admin_menu', 'rsvp_modify_menu');
1348 add_action('admin_init', 'rsvp_register_settings');
1349 add_action('init', 'rsvp_init');
1350 add_filter('the_content', 'rsvp_frontend_handler');
1351 register_activation_hook(__FILE__,'rsvp_database_setup');
1352 ?>
1353