query( "SELECT * FROM seminars WHERE is_finalized=0 AND visible=1 ORDER BY seminar_date ASC" )->fetchAll(); $open_seminars = array(); foreach ($all_open as $s) { if (!deadline_passed($s['signup_deadline'])) { $open_seminars[] = $s; } } // Apply series filter to the selector list (not to a directly-linked seminar) $open_seminars_filtered = array(); foreach ($open_seminars as $s) { if ($filter_series === 0 || (int)$s['series_id'] === $filter_series) { $open_seminars_filtered[] = $s; } } $seminar_id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if (!$seminar_id && count($open_seminars) === 1) { $seminar_id = (int)$open_seminars[0]['id']; } $seminar = null; $slots = array(); if ($seminar_id) { $st = $db->prepare("SELECT * FROM seminars WHERE id=?"); $st->execute(array($seminar_id)); $seminar = $st->fetch(); } if ($seminar) { $st = $db->prepare( "SELECT * FROM slots WHERE seminar_id=? AND slot_category IN ('individual','group') ORDER BY sort_order ASC, id ASC" ); $st->execute(array($seminar_id)); $slots = $st->fetchAll(); } /* --------------------------------------------------------------- Pre-load an existing signup when ?uid= is in the URL. This populates the form fields and slot buttons. --------------------------------------------------------------- */ $prefill = array( 'university_id' => '', 'person_name' => '', 'office_number' => '', ); $prefill_prefs = array(); // slot_id => preference (1 or 2) $existing_id = null; // signups.id of the record being edited $loaded_uid = false; // true when we successfully loaded an existing signup if ($seminar && isset($_GET['uid']) && trim($_GET['uid']) !== '') { $uid = trim($_GET['uid']); $st = $db->prepare( "SELECT * FROM signups WHERE seminar_id=? AND LOWER(university_id)=LOWER(?)" ); $st->execute(array($seminar_id, $uid)); $existing = $st->fetch(); if ($existing) { $existing_id = $existing['id']; $prefill['university_id'] = $existing['university_id']; $prefill['person_name'] = $existing['person_name']; $prefill['office_number'] = $existing['office_number']; $loaded_uid = true; $pst = $db->prepare( "SELECT slot_id, preference FROM slot_preferences WHERE signup_id=?" ); $pst->execute(array($existing_id)); foreach ($pst->fetchAll() as $p) { $prefill_prefs[$p['slot_id']] = (int)$p['preference']; } } } /* --------------------------------------------------------------- Handle POST submission --------------------------------------------------------------- */ $errors = array(); if ($_SERVER['REQUEST_METHOD'] === 'POST' && $seminar) { $university_id = trim(isset($_POST['university_id']) ? $_POST['university_id'] : ''); $person_name = trim(isset($_POST['person_name']) ? $_POST['person_name'] : ''); $office_number = trim(isset($_POST['office_number']) ? $_POST['office_number'] : ''); $prefs = isset($_POST['prefs']) && is_array($_POST['prefs']) ? $_POST['prefs'] : array(); if ($university_id === '') $errors[] = 'Please enter your university ID (e.g., healy.52).'; if ($person_name === '') $errors[] = 'Please enter your full name.'; if ($office_number === '') $errors[] = 'Please enter your office number.'; if (deadline_passed($seminar['signup_deadline'])) { $errors[] = 'The signup deadline has passed.'; } if (empty($errors)) { // Look up by university_id first; fall back to name for legacy records $chk = $db->prepare( "SELECT id FROM signups WHERE seminar_id=? AND LOWER(university_id)=LOWER(?)" ); $chk->execute(array($seminar_id, $university_id)); $existing = $chk->fetch(); if ($existing) { $signup_id = $existing['id']; $db->prepare( "UPDATE signups SET person_name=?, office_number=?, university_id=? WHERE id=?" )->execute(array($person_name, $office_number, $university_id, $signup_id)); $db->prepare("DELETE FROM slot_preferences WHERE signup_id=?") ->execute(array($signup_id)); } else { $db->prepare( "INSERT INTO signups (seminar_id, university_id, person_name, office_number) VALUES (?, ?, ?, ?)" )->execute(array($seminar_id, $university_id, $person_name, $office_number)); $signup_id = $db->lastInsertId(); } // Save slot preferences $ins = $db->prepare( "INSERT OR REPLACE INTO slot_preferences (signup_id, slot_id, preference) VALUES (?, ?, ?)" ); foreach ($prefs as $slot_id_raw => $pref_val) { $slot_id_clean = (int)$slot_id_raw; $pref_clean = ((int)$pref_val === 2) ? 2 : 1; if ($slot_id_clean > 0 && (int)$pref_val > 0) { $ins->execute(array($signup_id, $slot_id_clean, $pref_clean)); } } redirect( '/seminars/signup.php?id=' . $seminar_id . '&done=1&uid=' . urlencode($university_id) ); } // On error, re-populate fields from POST $prefill['university_id'] = $university_id; $prefill['person_name'] = $person_name; $prefill['office_number'] = $office_number; // Slot states come from $_POST['prefs'] directly in the template } /* --------------------------------------------------------------- Confirmation: load saved preferences to display --------------------------------------------------------------- */ $done_signup = null; $done_prefs = array(); if (isset($_GET['done']) && isset($_GET['uid']) && $seminar) { $uid = trim($_GET['uid']); $st = $db->prepare( "SELECT * FROM signups WHERE seminar_id=? AND LOWER(university_id)=LOWER(?)" ); $st->execute(array($seminar_id, $uid)); $done_signup = $st->fetch(); if ($done_signup) { $pst = $db->prepare( "SELECT slot_id, preference FROM slot_preferences WHERE signup_id=?" ); $pst->execute(array($done_signup['id'])); foreach ($pst->fetchAll() as $p) { $done_prefs[$p['slot_id']] = (int)$p['preference']; } } } /* --------------------------------------------------------------- Page output --------------------------------------------------------------- */ page_start('Sign Up for a Visit'); page_heading('Sign Up for a Speaker Visit'); ?>
Thanks, ! Your availability has been saved for ’s visit on .
Your selections

You didn’t mark any slots as available.

TimeEventYour preference
★ Preferred Available

Want to change your availability later? Use this personal link — bookmark it or keep it handy:

Or just return to the signup page and enter your university ID () — your choices will load automatically.

Edit my availability

There are no upcoming speaker visits currently accepting signups. Check the calendar for past schedules.
All series
Choose a visit

No visits currently accepting signups in this series. Show all series.

Signup deadline:
Visit details

Speaker

Date

Signup deadline:   Closed' : 'Open'; ?>

Signups for this visit have closed.
Loaded your existing signup for . Make any changes below and resubmit.
' . h($e) . '
'; endforeach; ?>
Your information

Your OSU name.# ID. Used to retrieve and update your signup later.

PhD students: use the visitor’s office ().

Your availability

Click each slot to mark your availability. Click once for Available, again for Preferred, again to clear. Slots you leave blank mean you’re not available.

prefill from DB > blank if ($_SERVER['REQUEST_METHOD'] === 'POST') { $init_state = isset($_POST['prefs'][$slot['id']]) ? (int)$_POST['prefs'][$slot['id']] : 0; } else { $init_state = isset($prefill_prefs[$slot['id']]) ? $prefill_prefs[$slot['id']] : 0; } ?>
(group event)