Example #1
0
<?php

Session::destroySession();
Session::setSuccess('You have been successfully logged out.');
// Redirect to homepage
Session::redirect('/login');
Example #2
0
            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');
}
Example #3
0
// 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']];
Example #4
0
<?php

/**
 * @var $page
 */
if ($page['user']['usertype'] != "1") {
    Session::setError('You are not able to accept an Offer');
    Session::redirect('/');
}
$offer = Offer::getOfferSingle($page['parameters']['id']);
if ($offer == null) {
    Session::setError('Offer does not exist');
    Session::redirect('/');
}
$advertisement = Advertisement::getAdvertisement($offer['advertisement']);
if ($advertisement['owner'] != $page['user']['id']) {
    Session::setError('You do not own this offers parent advertisement');
    Session::redirect('/');
}
if ($offer['status'] != "0") {
    Session::setError('Offer can not be accepted.');
    Session::redirect('/');
}
$accepted = Offer::acceptOffer($page['parameters']['id']);
if ($accepted) {
    Session::setSuccess('Successfully accepted offer');
    Session::redirect('/offers/view/' . $offer['advertisement']);
}
Session::setError('Something went wrong, please try again.');
Session::redirect('/offers/view/' . $offer['advertisement']);
Example #5
0
<?php

// Redirect to the home page if they are already logged in
if (User::isLoggedIn()) {
    Session::setError('You are already logged in.');
    Session::redirect('/');
}
// If the request is post, try and log them in
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // check whether the posted fields are empty
    if (!empty($_POST['login']['email']) && !empty($_POST['login']['password'])) {
        // try and log the user in
        if (User::attemptLogin($_POST['login']['email'], $_POST['login']['password'])) {
            $_SESSION['id'] = User::getUserId($_POST['login']['email']);
            Session::setSuccess('You have successfully been logged in.');
            Session::redirect('/profile');
        } else {
            Session::setError('Your Email or Password was incorrect or the account does not exist, please try again.');
            Session::redirect('/login');
        }
    } else {
        // set error message and redirect
        Session::setError('Unable to log you in, one or more fields was empty');
        Session::redirect('/login');
    }
}
Example #6
0
<?php

/**
 * @var $page
 */
if ($page['user']['usertype'] != "1") {
    Session::setError('You are not able to decline an Offer');
    Session::redirect('/');
}
$offer = Offer::getOfferSingle($page['parameters']['id']);
if ($offer == null) {
    Session::setError('Offer does not exist');
    Session::redirect('/');
}
$advertisement = Advertisement::getAdvertisement($offer['advertisement']);
if ($advertisement['owner'] != $page['user']['id']) {
    Session::setError('You do not own this offers parent advertisement');
    Session::redirect('/');
}
if ($offer['status'] != "0") {
    Session::setError('Offer can not be declined.');
    Session::redirect('/');
}
$declined = Offer::declineOffer($page['parameters']['id']);
if ($declined) {
    Session::setSuccess('Successfully declined offer');
    Session::redirect('/offers/view/' . $offer['advertisement']);
}
Session::setError('Something went wrong, please try again.');
Session::redirect('/offers/view/' . $offer['advertisement']);
Example #7
0
<?php

/**
 * @var $page
 */
if ($page['user']['usertype'] != "1") {
    Session::setError('You are not able to create an Advertisement');
    Session::redirect('/');
}
// if the form is posted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = Advertisement::getNextId();
    $startdate = strtotime($_POST['advertisement']['startdate']);
    $enddate = strtotime($_POST['advertisement']['enddate']);
    $newAdvertisement = Advertisement::createAdvertisement(User::getId(), $_POST['advertisement']['title'], $startdate, $enddate, $_POST['advertisement']['description'], $_POST['advertisement']['location'], $_POST['advertisement']['category'], $_POST['advertisement']['salary'], $_POST['advertisement']['tags']);
    if ($newAdvertisement) {
        Session::setSuccess('Successfully created advertisement!');
        Session::redirect('/advertisement/' . $id);
    }
    Session::setError('Unable to create advertisement, an unknown error occured, please try again');
    Session::redirect('/');
}
Example #8
0
<?php

/**
 * @var $page
 */
if ($page['user'] != null) {
    Session::setError('You are already signed up!');
    Session::redirect('/profile');
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $createUser = User::createUser($_POST['signup']);
    if ($createUser) {
        Session::setSuccess('Signup successful! You can now login.');
        Session::redirect('/login');
    }
    Session::setError('Unable to sign you up, please try again.');
    Session::redirect('/signup');
}
Example #9
0
<?php

// If the request is a post
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $bookingId = $_POST['bookingId'];
    $oneWeek = $_POST['reminder']['oneWeek'];
    $threeDays = $_POST['reminder']['threeDays'];
    $oneDay = $_POST['reminder']['oneDay'];
    if ($oneWeek === null) {
        $oneWeek = "0";
    }
    if ($threeDays === null) {
        $threeDays = "0";
    }
    if ($oneDay === null) {
        $oneDay = "0";
    }
    if (Notification::setNotification($bookingId, $oneWeek, $threeDays, $oneDay)) {
        Session::setSuccess('Set reminders successfully.');
        Session::redirect('/bookings');
    }
    Session::setError('Unable to set reminders, please try again.');
    Session::redirect('/bookings');
} else {
    Session::setError('Unable to set reminders, please try again.');
    Session::redirect('/bookings');
}
Example #10
0
<?php

/**
 * @var $page
 */
if ($page['user']['usertype'] != "1") {
    Session::setError('You are not able to close an Advertisement');
    Session::redirect('/');
}
$advertisement = Advertisement::getAdvertisement($page['parameters']['id']);
if ($advertisement == null) {
    Session::setError('Advertisement does not exist');
    Session::redirect('/');
}
if ($advertisement['status'] == "2") {
    Session::setError('Advertisement is already closed');
    Session::redirect('/advertisement/' . $page['parameters']['id']);
}
$closed = Advertisement::close($page['parameters']['id']);
if ($closed) {
    Session::setSuccess('Successfully closed advertisement');
    Session::redirect('/advertisement/' . $page['parameters']['id']);
}
Session::setError('Something went wrong, please try again.');
Session::redirect('/advertisement/' . $page['parameters']['id']);
Example #11
0
// Make sure the user is a user that can make an offer
$user = User::getUser();
if ($user['usertype'] != "0") {
    Session::setError('You are not the correct user type to make an offer');
    Session::redirect('/');
}
// Make sure it is a valid advertisement and it can take offers
$advertisement = Advertisement::getAdvertisement($page['parameters']['id']);
if ($advertisement == null || $advertisement['status'] != "1") {
    Session::setError('This advertisement does not exist or is not able to be offered.');
    Session::redirect('/');
}
$page['advertisement'] = $advertisement;
// Check if this user has already made an offer
$offers = Offer::getOffersForUser(User::getId());
foreach ($offers as $offer) {
    if ($offer['advertisement'] == $page['parameters']['id']) {
        Session::setError('You have already sent an offer for this Advertisement.');
        Session::redirect('/advertisement/' . $page['parameters']['id']);
    }
}
// if the form is posted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $newOffer = Offer::createOffer(User::getId(), $page['parameters']['id'], $_POST['makeOffer']['description']);
    if ($newOffer) {
        Session::setSuccess('Successfully added offer!');
        Session::redirect('/profile');
    }
    Session::setError('Unable to create offer, an unknown error occured, please try again');
    Session::redirect('/advertisement/' . $page['parameters']['id']);
}
Example #12
0
<?php

/**
 * @var $page
 */
if ($page['user']['usertype'] != "1") {
    Session::setError('You are not able to close an Advertisement');
    Session::redirect('/');
}
$advertisement = Advertisement::getAdvertisement($page['parameters']['id']);
if ($advertisement == null) {
    Session::setError('Advertisement does not exist');
    Session::redirect('/');
}
if ($advertisement['status'] == "1") {
    Session::setError('Advertisement is already open');
    Session::redirect('/advertisement/' . $page['parameters']['id']);
}
$closed = Advertisement::open($page['parameters']['id']);
if ($closed) {
    Session::setSuccess('Successfully opened advertisement');
    Session::redirect('/advertisement/' . $page['parameters']['id']);
}
Session::setError('Something went wrong, please try again.');
Session::redirect('/advertisement/' . $page['parameters']['id']);
Example #13
0
<?php

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    Session::setSuccess('Message sent successfully!');
    Session::redirect('/contact');
}
Example #14
0
foreach ($page['offers'] as &$offer) {
    // trim the description
    if (strlen($offer['description']) > 150) {
        $offer['description'] = substr($offer['description'], 0, 150) . '...';
    }
    $offer['parentAdvertisement'] = Advertisement::getAdvertisement($offer['advertisement']);
    // get the owner details if the offer has been accepted
    if ($offer['status'] == "1" || $offer['status'] == "3") {
        $offer['ownerDetails'] = User::getUser($offer['parentAdvertisement']['owner']);
    }
    if ($offer['status'] == "3") {
        $offer['yourRating'] = Rating::getRating($offer['id'], User::getId());
        if ($offer['yourRating'] != null) {
            $offer['yourRating']['rating'] = Rating::getStarsArray($offer['yourRating']['rating']);
        }
        $offer['theirRating'] = Rating::getRating($offer['id'], $offer['ownerDetails']['id']);
        if ($offer['theirRating'] != null) {
            $offer['theirRating']['rating'] = Rating::getStarsArray($offer['theirRating']['rating']);
        }
    }
}
// if it is posted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $updateUser = User::updateUser($_POST['profile']);
    if ($updateUser) {
        Session::setSuccess('Details updated successfully!');
        Session::redirect('/profile');
    }
    Session::setError('Unable to update details, please try again.');
    Session::redirect('/profile');
}
Example #15
0
// if the form is posted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $ratingScore = (int) $_POST['rating']['score'];
    if ($ratingScore > 5) {
        $ratingScore = 5;
    } elseif ($ratingScore < 1) {
        $ratingScore = 1;
    }
    // create the rating
    if ($page['user']['usertype'] == "1") {
        $newRating = Rating::createRating($offer['owner'], $offer['id'], $advertisement['id'], $ratingScore, $_POST['rating']['comments']);
    } else {
        $newRating = Rating::createRating($advertisement['owner'], $offer['id'], $advertisement['id'], $ratingScore, $_POST['rating']['comments']);
    }
    if ($newRating) {
        // try and complete the offer
        Offer::completeOffer($offer['id']);
        Session::setSuccess('Successfully created rating!');
        if ($page['user']['usertype'] == "1") {
            Session::redirect('/advertisement/' . $offer['advertisement']);
        } else {
            Session::redirect('/profile');
        }
    }
    Session::setError('Unable to create rating, an unknown error occured, please try again');
    if ($page['user']['usertype'] == "1") {
        Session::redirect('/advertisement/' . $offer['advertisement']);
    } else {
        Session::redirect('/profile');
    }
}
Example #16
0
<?php

$page['maxstrikes'] = User::getMaxStrikes();
$page['educational-backgrounds'] = ['hsc' => ['label' => 'HSC', 'key' => 'hsc', 'sql' => 'hsc'], 'ielts' => ['label' => 'IELTS', 'key' => 'ielts', 'sql' => 'ielts'], 'toefl' => ['label' => 'TOEFL', 'key' => 'toefl', 'sql' => 'toefl'], 'tafe' => ['label' => 'TAFE', 'key' => 'tafe', 'sql' => 'tafe'], 'cult' => ['label' => 'CULT', 'key' => 'cult', 'sql' => 'cult'], 'insearchDeep' => ['label' => 'Insearch DEEP', 'key' => 'insearchDeep', 'sql' => 'insearch_deep'], 'insearchDiploma' => ['label' => 'Insearch Diploma', 'key' => 'insearchDiploma', 'sql' => 'insearch_diploma'], 'foundationCourse' => ['label' => 'Foundation Course', 'key' => 'foundationCourse', 'sql' => 'foundation_course']];
foreach ($page['educational-backgrounds'] as &$educationalBackground) {
    $educationalBackground['checked'] = $page['user'][$educationalBackground['sql']];
    $educationalBackground['value'] = $page['user'][$educationalBackground['sql'] . '_mark'];
}
// If the request is post, try and sign them up
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    foreach ($_POST['userinformation'] as $key => $value) {
        if (is_array($value)) {
            $result = User::setEducation($value);
        } else {
            $result = User::setAttribute($key, $value);
        }
        if ($result == false) {
            Session::setError('Unable to update your information, please try again.');
            Session::redirect('/profile');
        }
    }
    foreach ($_POST['notifications'] as $key => $value) {
        $result = User::setAttribute($key, $value);
        if ($result == false) {
            Session::setError('Unable to update your information, please try again.');
            Session::redirect('/profile');
        }
    }
    Session::setSuccess('Successfully updated your information!');
    Session::redirect('/profile');
}