Пример #1
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']];
Пример #2
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');
    }
}
Пример #3
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');
}
Пример #4
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('/');
}
Пример #5
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']);
Пример #6
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');
}
Пример #7
0
 /**
  * Create a new user
  *
  * @param $details
  * @return bool
  */
 static function createUser($details)
 {
     // Make sure the email doesn't already exist
     if (self::getUserId($details['email']) != null) {
         Session::setError('Email has already been used before, please use a different one.');
         Session::redirect('/signup');
     }
     $id = self::getNextId();
     if ($details['user-type'] == "employer") {
         $usertype = 1;
     } else {
         $usertype = 0;
     }
     if ($details['password'] == $details['confirm-password']) {
         $password = self::hashPassword($details['password']);
     } else {
         $password = '';
         Session::setError('Passwords do not match, please try again.');
         Session::redirect('/signup');
     }
     $mysql = new MySQL();
     $results = $mysql->query('INSERT INTO user(id, usertype, name, email, password, contactno, aboutme, qualifications, website, companyname, companylocation, availability) VALUES (:id, :usertype, :name, :email, :password, :contactno, :aboutme, :qualifications, :website, :companyname, :companylocation, :availability)', [':id' => $id, ':usertype' => $usertype, ':name' => $details['name'], ':email' => $details['email'], ':password' => $password, ':contactno' => $details['contactno'], ':aboutme' => $details['aboutme'], ':qualifications' => $details['qualifications'], ':website' => $details['website'], ':companyname' => $details['companyname'], ':companylocation' => $details['companylocation'], ':availability' => $details['availability']]);
     return $results['success'];
 }
Пример #8
0
 * @var $page
 */
// make sure user can view this page
if ($page['user']['usertype'] != "1") {
    Session::setError('You are not able to view offers for an advertisement');
    Session::redirect('/');
}
// make sure is valid advertisement
$advertisement = Advertisement::getAdvertisement($page['parameters']['id']);
if ($advertisement == null) {
    Session::setError('Advertisement does not exist.');
    Session::redirect('/');
}
// make sure the advertisement is owned by the user
if ($advertisement['owner'] != $page['user']['id']) {
    Session::setError('You do not own this advertisement');
    Session::redirect('/');
}
$page['advertisement'] = $advertisement;
$offers = Offer::getOffersForAdvertisement($advertisement['id']);
$page['offers'] = $offers;
foreach ($page['offers'] as &$offer) {
    $offer['ownerDetails'] = User::getUser($offer['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']);
Пример #9
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');
}
Пример #10
0
<?php

$page['loggedin'] = false;
if (User::isLoggedIn()) {
    // If it's the user's first use, make sure they register
    if (User::firstUse()) {
        Session::setError('You have to register first before using this service.');
        Session::redirect('/register');
    }
    $page['loggedin'] = true;
    // search for the users bookings
    $bookings = UTSHelpsAPI::SearchWorkshopBookings(['studentId' => User::getPaddedId(), 'pageSize' => 9999, 'active' => true]);
    $currentTime = strtotime(Session::getCurrentDateTime());
    $count = 0;
    // Get all the upcoming bookings
    if ($bookings != null && $bookings->IsSuccess == 1) {
        foreach ($bookings->Results as $booking) {
            // if booking archived field does not have a date, it hasn't been canceled or attended
            if ($booking->BookingArchived == null && strtotime($booking->starting) > $currentTime && $booking->canceled === null && $booking->attended === null) {
                $count++;
            }
        }
    }
    $page['bookingCount'] = $count;
    // Get all of the workshops for the workshop listings
    $workshops = UTSHelpsAPI::ListWorkshopSets(true);
    if ($workshops != null && $workshops->IsSuccess == 1) {
        $page['workshops'] = count($workshops->Results);
    } else {
        $page['workshops'] = 0;
    }
Пример #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']);
}
Пример #12
0
<?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);
Пример #13
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');
}
Пример #14
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');
}