<?php $sessionsNonActive = UTSHelpsAPI::ListSessionTypes(false); $sessionsActive = UTSHelpsAPI::ListSessionTypes(true); if ($sessionsActive != null && $sessionsActive->IsSuccess == 1) { $page['sessionsActive'] = $sessionsActive; } else { $page['sessionsActive'] = null; } if ($sessionsNonActive != null && $sessionsNonActive->IsSuccess == 1) { $page['sessionsNonActive'] = $sessionsNonActive; } else { $page['sessionsNonActive'] = null; }
<?php /** * @var $page */ /** * Compare two workshop names * * @param $a * @param $b * @return int */ function compareByName($a, $b) { return strcmp($a->name, $b->name); } $workshops = UTSHelpsAPI::ListWorkshopSets(true); if ($workshops != null && $workshops->IsSuccess == 1) { $page['workshops'] = $workshops->Results; usort($page['workshops'], 'compareByName'); } else { $page['workshops'] = null; }
if ($value->BookingArchived == null && $value->attended == null && strtotime(Session::getCurrentDateTime()) > strtotime($value->starting)) { $page['booking'] = $value; } else { Session::setError('Booking has not been completed, please try again.'); Session::redirect('/bookings'); } } } } if ($page['booking'] == null) { Session::setError('Booking does not exist, please try again.'); Session::redirect('/bookings'); } // Make sure attendance hasn't already been recorded for this booking, // or the booking hasn't been set as cancelled $attendance = Attendance::getAttendance($bookingId); if ($attendance != null) { Session::setError('You have already recorded attendance for this workshop.'); Session::redirect('/bookings'); } // If the request is a post if ($_SERVER['REQUEST_METHOD'] === 'POST') { $createNonAttendance = Attendance::createNonAttendance($bookingId, $page['booking']->workshopID); $updateBooking = UTSHelpsAPI::UpdateWorkshopBooking(['workshopId' => $page['booking']->workshopID, 'studentId' => User::getPaddedId(), 'Attended' => 0, 'Canceled' => 0, 'userId' => 123]); if ($createNonAttendance && $updateBooking != null && $updateBooking->IsSuccess == 1 && User::addStrike()) { Session::setSuccess('Successfully recorded non-attendance for this booking.'); Session::redirect('/bookings'); } Session::setError('Unable to record non-attendance for this booking, please try again.'); Session::redirect('/bookings'); }
// Make sure this is the first time // the user has used the website if (!User::firstUse()) { Session::setError('Cannot register, you have already registered before.'); Session::redirect('/'); } // If the request is post, try and sign them up if ($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($_POST['register'] as $key => $value) { if (is_array($value)) { $result = User::setEducation($value); } else { $result = User::setAttribute($key, $value); } if ($result == false) { Session::setError('Unable to complete your registration, please try again.'); Session::redirect('/register'); } } $user = User::getUser(); $registration = UTSHelpsAPI::RegisterStudent(['StudentId' => $user['student_id'], 'DateOfBirth' => $user['dob'], 'Gender' => $user['gender'], 'Degree' => $user['degree'], 'Status' => $user['status'], 'FirstLanguage' => $user['first_language'], 'CountryOrigin' => $user['country_of_origin'], 'DegreeDetails' => $user['year'], 'AltContact' => $user['best_contact_no'], 'PreferredName' => $user['preferred_first_name'], 'HSC' => (bool) $user['hsc'], 'HSCMark' => $user['hsc_mark'], 'IELTS' => (bool) $user['ielts'], 'IELTSMark' => $user['ielts_mark'], 'TOEFL' => (bool) $user['toefl'], 'TOEFLMark' => $user['toefl_mark'], 'TAFE' => (bool) $user['tafe'], 'TAFEMark' => $user['tafe_mark'], 'CULT' => (bool) $user['cult'], 'CULTMark' => $user['cult_mark'], 'InsearchDEEP' => (bool) $user['insearch_deep'], 'InsearchDEEPMark' => $user['insearch_deep_mark'], 'InsearchDiploma' => (bool) $user['insearch_diploma'], 'InsearchDiplomaMark' => $user['insearch_diploma_mark'], 'FoundationCourse' => (bool) $user['foundation_course'], 'FoundationCourseMark' => $user['foundation_course_mark'], 'CreatorId' => 123456]); $message = Notification::renderEmail('emails/registration.html', ['name' => $user['name']]); Notification::sendEmail($user['email'], $user['name'], 'Registration Successful', $message); User::setFirstUse(); User::setLastLogin(); Session::setSuccess('You have successfully saved your registration details.'); Session::redirect('/'); } // Get the user $page['user'] = User::getUser(); $page['educational-backgrounds'] = ['hsc' => ['label' => 'HSC', 'key' => 'hsc'], 'ielts' => ['label' => 'IELTS', 'key' => 'ielts'], 'toefl' => ['label' => 'TOEFL', 'key' => 'toefl'], 'tafe' => ['label' => 'TAFE', 'key' => 'tafe'], 'cult' => ['label' => 'CULT', 'key' => 'cult'], 'insearchDeep' => ['label' => 'Insearch DEEP', 'key' => 'insearchDeep'], 'insearchDiploma' => ['label' => 'Insearch Diploma', 'key' => 'insearchDiploma'], 'foundationCourse' => ['label' => 'Foundation Course', 'key' => 'foundationCourse']];
// Make sure the id is specified if (!array_key_exists('bookingId', $_POST) && !array_key_exists('workshopId', $_POST) && $_POST['bookingId'] == null && $_POST['workshopId'] == null) { Session::returnJsonMessage(['success' => false, 'message' => 'No booking ID or workshop ID provided, unable to cancel booking.']); } $bookingId = $_POST['bookingId']; $workshopId = $_POST['workshopId']; // Make sure the booking actually exists $bookings = UTSHelpsAPI::SearchWorkshopBookings(['studentId' => User::getPaddedId(), 'pageSize' => 9999, 'active' => true]); if ($bookings != null && $bookings->IsSuccess == 1) { // Make sure the booking exists $found = false; foreach ($bookings->Results as $booking) { if ($booking->BookingId == (int) $bookingId && $booking->workshopID == (int) $workshopId) { $found = true; } } if ($found == false) { Session::returnJsonMessage(['success' => false, 'message' => 'This booking does not exist, unable to cancel booking.']); } } else { Session::returnJsonMessage(['success' => false, 'message' => 'Unable to cancel booking, an unknown error occured.']); } $updatedBookings = UTSHelpsAPI::UpdateWorkshopBooking(['workshopId' => $workshopId, 'studentId' => User::getPaddedId(), 'Canceled' => 1, 'Attended' => 0, 'userId' => 123]); if ($updatedBookings != null && $updatedBookings->IsSuccess == 1) { // The booking exists, we can safely cancel it. $canceledBooking = UTSHelpsAPI::CancelWorkshopBooking(['workshopId' => $workshopId, 'studentId' => User::getPaddedId(), 'userId' => 123]); if ($canceledBooking != null && $canceledBooking->IsSuccess == 1) { Session::returnJsonMessage(['success' => true, 'message' => 'Successfully cancelled booking!']); } } Session::returnJsonMessage(['success' => false, 'message' => 'Unable to cancel booking, please try again.']);
<?php $bookingId = (int) $page['parameters']['bookingId']; $bookings = UTSHelpsAPI::SearchWorkshopBookings(['studentId' => User::getPaddedId(), 'pageSize' => 9999, 'active' => true]); $page['booking'] = null; if ($bookings != null && $bookings->IsSuccess == 1) { foreach ($bookings->Results as $value) { if ($value->BookingId == $bookingId) { if ($value->BookingArchived == null && $value->attended == 1 && strtotime(Session::getCurrentDateTime()) > strtotime($value->starting)) { $page['booking'] = $value; } else { Session::setError('Booking has not been completed, please try again.'); Session::redirect('/bookings'); } } } } if ($page['booking'] == null) { Session::setError('Booking does not exist, please try again.'); Session::redirect('/bookings'); } $page['attendance'] = Attendance::getAttendance($bookingId);
// Make sure the id is specified if (!array_key_exists('id', $_POST) && $_POST['id'] == null) { Session::returnJsonMessage(['success' => false, 'message' => 'No workshop ID provided, unable to book workshop.']); } $id = $_POST['id']; // Check if the person hasn't already signed up to the workshop before $bookings = UTSHelpsAPI::SearchWorkshopBookings(['studentId' => User::getPaddedId(), 'pageSize' => 9999, 'active' => true]); if ($bookings != null && $bookings->IsSuccess == 1) { // Make sure the user hasn't already booked this workshop before. foreach ($bookings->Results as $booking) { if ($booking->workshopID == (int) $id && $booking->BookingArchived == null) { Session::returnJsonMessage(['success' => false, 'message' => 'You have already booked this workshop, unable to book workshop.']); } } } else { Session::returnJsonMessage(['success' => false, 'message' => 'Unable to book workshop, an unknown error occured.']); } // If the user has too many strikes, don't allow them to book. if (User::getStrikes() >= User::getMaxStrikes()) { Session::returnJsonMessage(['success' => false, 'message' => 'Unable to create booking, you have too many strikes.']); } // This user hasn't booked the workshop before, we can safely book it now. $booking = UTSHelpsAPI::CreateWorkshopBooking(['workshopId' => $id, 'studentId' => User::getPaddedId(), 'userId' => 123]); if ($booking != null && $booking->IsSuccess == 1) { // Send the email notification to the user $user = User::getUser(); $message = Notification::renderEmail('emails/booking.html', ['name' => $user['name'], 'workshopId' => $id]); Notification::sendEmail($user['email'], $user['name'], 'Booking Created', $message); Session::returnJsonMessage(['success' => true, 'message' => 'Successfully booked workshop!']); } Session::returnJsonMessage(['success' => false, 'message' => 'Unable to create booking, please try again.']);
<?php // Make sure the id is specified if (!array_key_exists('id', $_POST) && $_POST['id'] == null) { Session::returnJsonMessage(['success' => false, 'message' => 'No workshop ID provided, unable to join workshop waiting list.']); } $id = $_POST['id']; $waitinglist = UTSHelpsAPI::CreateWorkshopWaiting(['workshopId' => $id, 'studentId' => User::getPaddedId(), 'userId' => '123']); if ($waitinglist != null && $waitinglist->IsSuccess == 1) { // Send the email notification $user = User::getUser(); $message = Notification::renderEmail('emails/waiting-list.html', ['name' => $user['name'], 'workshopId' => $id]); Notification::sendEmail($user['email'], $user['name'], 'Joined Waiting List', $message); Session::returnJsonMessage(['success' => true, 'message' => 'Successfully joined waiting list!']); } Session::returnJsonMessage(['success' => false, 'message' => 'Unable to join waiting list, you have already joined it.']);
return $a['startDate'] - $b['startDate']; } /** * Compares start dates for sorting in a reverse fashion * * @param $b * @param $a * @return mixed */ function compareStartDateReverse($b, $a) { return $a['startDate'] - $b['startDate']; } $currentTime = strtotime(Session::getCurrentDateTime()); $bookings = UTSHelpsAPI::SearchWorkshopBookings(['studentId' => User::getPaddedId(), 'pageSize' => 9999, 'active' => true]); $campuses = UTSHelpsAPI::ListCampuses(true); if ($campuses != null && $campuses->IsSuccess == 1) { $page['campuses'] = $campuses->Results; } else { $page['campuses'] = null; } if ($bookings != null && $bookings->IsSuccess == 1) { foreach ($bookings->Results as $value) { $startDate = strtotime($value->starting); $endDate = strtotime($value->ending); $startTime = date("g:ia", $startDate); $endTime = date("g:ia", $endDate); $date = date("jS M Y", $startDate) . ': ' . $startTime . ' - ' . $endTime; $location = null; if ($page['campuses'] != null) { foreach ($page['campuses'] as $campus) {