コード例 #1
0
ファイル: register.php プロジェクト: Outlaw11A/SDP2015
// 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']];
コード例 #2
0
ファイル: attendance.php プロジェクト: Outlaw11A/SDP2015
        $page['field']['taught'] = $_POST['attendance']['taught'];
        $page['field']['learn'] = $_POST['attendance']['learn'];
    } else {
        // Make sure the file name does not contain php in it
        if (strpos($_FILES['attendance']['name']['file'], 'php')) {
            Session::setError('File rejected');
            Session::redirect('/bookings');
        }
        // Make the filename
        $extension = pathinfo($_FILES['attendance']['name']['file'], PATHINFO_EXTENSION);
        $filename = Attendance::generateRandomFileName() . '.' . $extension;
        // Upload file path
        $uploadedFile = $GLOBALS['file-directory'] . basename($filename);
        if (!move_uploaded_file($_FILES['attendance']['tmp_name']['file'], $uploadedFile)) {
            Session::setError('Unable to upload file, please try again.');
            Session::redirect('/bookings');
        }
        $createAttendance = Attendance::createAttendance($bookingId, $page['booking']->workshopID, $_POST['attendance']['learn'], $_POST['attendance']['taught'], $filename);
        $updateBooking = UTSHelpsAPI::UpdateWorkshopBooking(['workshopId' => $page['booking']->workshopID, 'studentId' => User::getPaddedId(), 'Attended' => 1, 'Canceled' => 0, 'userId' => 123]);
        if ($createAttendance && $updateBooking != null && $updateBooking->IsSuccess == 1) {
            // Send the email notification
            $user = User::getUser();
            $message = Notification::renderEmail('emails/record-attendance.html', ['name' => $user['name'], 'bookingId' => $bookingId]);
            Notification::sendEmail($user['email'], $user['name'], 'Recorded Attendance', $message);
            Session::setSuccess('Successfully recorded attendance for this booking.');
            Session::redirect('/bookings');
        }
        Session::setError('Unable to record attendance for this booking, please try again.');
        Session::redirect('/bookings');
    }
}
コード例 #3
0
<?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.']);
コード例 #4
0
ファイル: book.php プロジェクト: Outlaw11A/SDP2015
// 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.']);
コード例 #5
0
ファイル: admin_routes.php プロジェクト: vanderlin/halp
         $data = ['task' => $notice->task, 'extra' => '<a style="position: fixed; bottom:0; text-align:center;padding:25px 0;background-color:#FF6666;width:100%;color:white;font-family: Montserrat, Arial, sans-serif;text-transform:uppercase;font-size:12px;letter-spacing:1px;" href="' . $back_url . '">Back to Admin</a>'];
         // award info
         if (Input::get('event') == Notification::NOTIFICATION_NEW_AWARD) {
             $data['award'] = new Award(['user_id' => Auth::id(), 'project_id' => Project::getRandomID(), 'name' => Input::get('award_type', Award::AWARD_CLAIMED_5)]);
         }
         // get emails
         $emails = explode(',', Input::get('emails', '*****@*****.**'));
         // filter fake ones
         $emails = array_filter($emails, function ($a) {
             if (filter_var($a, FILTER_VALIDATE_EMAIL)) {
                 return $a;
             }
         });
         $pre_render = Input::get('pre_render', false) == "on" ? true : false;
         if (Input::get('view')) {
             return $notice->renderEmail($data)->downloadHtml();
         }
         // get the subject
         $subject = Input::get('subject', Auth::user()->getName() . " Halp Email Test:" . $notice->event . " " . uniqid());
         $status = $notice->sendEmailToGroup($emails, $subject, $data);
         return ['status' => $status, 'notice' => $notice, 'input' => Input::all()];
         dd($notice);
     });
 });
 // ------------------------------------------------------------------------
 // Notifications
 // ------------------------------------------------------------------------
 Route::group(['prefix' => 'notifications'], function () {
     Route::get('/', function () {
         return View::make('admin.notifications.index', ['active_link' => 'notifications', 'notifications' => Notification::orderBy('created_at', 'DESC')->get()]);
     });