comments
This commit is contained in:
parent
dd6c8d1cab
commit
5cbd031279
|
|
@ -20,14 +20,14 @@ class DatabaseTable {
|
||||||
$this->pdo = new \PDO('mysql:dbname='.$this->schema.';host='.$this->server, $this->username, $this->password);
|
$this->pdo = new \PDO('mysql:dbname='.$this->schema.';host='.$this->server, $this->username, $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function insert($record) {
|
private function insert($record) { //Insert record into table
|
||||||
$keys = \array_keys($record);
|
$keys = \array_keys($record);
|
||||||
$columns = \implode(', ', $keys);
|
$columns = \implode(', ', $keys);
|
||||||
$values = \implode(', :', $keys);
|
$values = \implode(', :', $keys);
|
||||||
$this->pdo->prepare('INSERT INTO '. $this->table . ' (' . $columns . ') VALUES (:' . $values . ')')->execute($record);
|
$this->pdo->prepare('INSERT INTO '. $this->table . ' (' . $columns . ') VALUES (:' . $values . ')')->execute($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function update($record) {
|
private function update($record) { //Update record in table
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach ($record as $key => $value) {
|
foreach ($record as $key => $value) {
|
||||||
$params[] = $key . ' = :' .$key;
|
$params[] = $key . ' = :' .$key;
|
||||||
|
|
@ -36,7 +36,7 @@ class DatabaseTable {
|
||||||
$this->pdo->prepare('UPDATE '. $this->table .' SET '. \implode(', ', $params) .' WHERE '. $this->pk .' = :primaryKey')->execute($record);
|
$this->pdo->prepare('UPDATE '. $this->table .' SET '. \implode(', ', $params) .' WHERE '. $this->pk .' = :primaryKey')->execute($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find($columns, $values, $comparators = ['=', '='], $order = "ASC", $orderColumn = "id") {
|
public function find($columns, $values, $comparators = ['=', '='], $order = "ASC", $orderColumn = "id") { //Find rows in table
|
||||||
$string = 'SELECT * FROM '.$this->table.' WHERE ';
|
$string = 'SELECT * FROM '.$this->table.' WHERE ';
|
||||||
for ($i = 0; $i < count($values); $i++) {
|
for ($i = 0; $i < count($values); $i++) {
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
|
|
@ -51,21 +51,21 @@ class DatabaseTable {
|
||||||
return $stmt->fetchAll();
|
return $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll() {
|
public function findAll() { //Find all rows in table
|
||||||
$stmt = $this->pdo->prepare('SELECT * FROM ' . $this->table);
|
$stmt = $this->pdo->prepare('SELECT * FROM ' . $this->table);
|
||||||
$stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor);
|
$stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
return $stmt->fetchAll();
|
return $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($column, $value) {
|
public function delete($column, $value) { //Delete row from table
|
||||||
$values = [
|
$values = [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
];
|
];
|
||||||
$this->pdo->prepare('DELETE FROM '. $this->table .' WHERE '. $column .' = :value')->execute($values);
|
$this->pdo->prepare('DELETE FROM '. $this->table .' WHERE '. $column .' = :value')->execute($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save($record) {
|
public function save($record) { //Save record to table
|
||||||
if (empty($record[$this->pk])) {
|
if (empty($record[$this->pk])) {
|
||||||
unset($record[$this->pk]);
|
unset($record[$this->pk]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@ class EntryPoint {
|
||||||
$this->routes = $routes;
|
$this->routes = $routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadTemplate($fileName, $templateData) {
|
public function loadTemplate($fileName, $templateData) { //Load HTML template
|
||||||
\extract($templateData);
|
\extract($templateData);
|
||||||
\ob_start();
|
\ob_start();
|
||||||
require $fileName;
|
require $fileName;
|
||||||
return \ob_get_clean();
|
return \ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() { //run response
|
||||||
$route = \ltrim(\explode('?', $_SERVER['REQUEST_URI'])[0], '/');
|
$route = \ltrim(\explode('?', $_SERVER['REQUEST_URI'])[0], '/');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class Routes {
|
||||||
$this->loginControllers = [];
|
$this->loginControllers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getController($controllerName, $functionName) {
|
public function getController($controllerName, $functionName) { //get controller
|
||||||
|
|
||||||
$this->checkLogin($controllerName);
|
$this->checkLogin($controllerName);
|
||||||
|
|
||||||
|
|
@ -29,11 +29,11 @@ class Routes {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultRoute() {
|
public function getDefaultRoute() { //Default request route
|
||||||
return 'controller/home';
|
return 'controller/home';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkLogin($name) {
|
public function checkLogin($name) { //Check if controller requires user to be logged in
|
||||||
$requiresLogin = $this->loginControllers[$name] ?? false;
|
$requiresLogin = $this->loginControllers[$name] ?? false;
|
||||||
|
|
||||||
if ($requiresLogin && !isset($_SESSION['loggedin'])) {
|
if ($requiresLogin && !isset($_SESSION['loggedin'])) {
|
||||||
|
|
@ -42,7 +42,7 @@ class Routes {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//404 Page
|
||||||
public function notFound() {
|
public function notFound() {
|
||||||
return ['template' => 'response.html.php',
|
return ['template' => 'response.html.php',
|
||||||
'title' => '404 Not Found',
|
'title' => '404 Not Found',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs\Entity;
|
namespace jobs\Entity;
|
||||||
class Applicant {
|
class Applicant { //Represents Applicant Entity from applicants table
|
||||||
public $id;
|
public $id;
|
||||||
public $name;
|
public $name;
|
||||||
public $email;
|
public $email;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs\Entity;
|
namespace jobs\Entity;
|
||||||
class Category {
|
class Category { //Represents category Entity from categories table
|
||||||
public $id;
|
public $id;
|
||||||
public $name;
|
public $name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs\Entity;
|
namespace jobs\Entity;
|
||||||
class Enquiry {
|
class Enquiry { //Represents enquiry Entity from enquiries table
|
||||||
public $id;
|
public $id;
|
||||||
public $name;
|
public $name;
|
||||||
public $email;
|
public $email;
|
||||||
|
|
@ -14,7 +14,7 @@ class Enquiry {
|
||||||
$this->usersTable = $usersTable;
|
$this->usersTable = $usersTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdmin() {
|
public function getAdmin() { //Get the admin that completed the enquiry
|
||||||
if ($this->completed == 'y') {
|
if ($this->completed == 'y') {
|
||||||
return $this->usersTable->find(['id'], ['value0' => $this->admin_id])[0];
|
return $this->usersTable->find(['id'], ['value0' => $this->admin_id])[0];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs\Entity;
|
namespace jobs\Entity;
|
||||||
class Job {
|
class Job { //Represents Job Entity from jobs table
|
||||||
public $id;
|
public $id;
|
||||||
public $title;
|
public $title;
|
||||||
public $description;
|
public $description;
|
||||||
|
|
@ -18,11 +18,11 @@ class Job {
|
||||||
$this->appsTable = $appsTable;
|
$this->appsTable = $appsTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCat() {
|
public function getCat() { //Get category job is in
|
||||||
return $this->catsTable->find(['id'], ['value0' => $this->categoryId])[0];
|
return $this->catsTable->find(['id'], ['value0' => $this->categoryId])[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getApps() {
|
public function getApps() { //Get applicants for job
|
||||||
return $this->appsTable->find(['jobId'], ['value0' => $this->id]);
|
return $this->appsTable->find(['jobId'], ['value0' => $this->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs\Entity;
|
namespace jobs\Entity;
|
||||||
class User {
|
class User { //Represents User Entity from userss table
|
||||||
public $id;
|
public $id;
|
||||||
public $username;
|
public $username;
|
||||||
public $password;
|
public $password;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs;
|
namespace jobs;
|
||||||
class JobDatabaseTable extends \CSY2028\DatabaseTable {
|
class JobDatabaseTable extends \CSY2028\DatabaseTable { //Represents A table from the schema for this site
|
||||||
protected $server = 'mysql';
|
protected $server = 'mysql';
|
||||||
protected $username = 'student';
|
protected $username = 'student';
|
||||||
protected $password = 'student';
|
protected $password = 'student';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
namespace jobs;
|
namespace jobs;
|
||||||
class Routes extends \CSY2028\Routes {
|
class Routes extends \CSY2028\Routes { //Represents the routes for this site
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,22 @@ class Jobs {
|
||||||
$this->enquiryTable = $enquiryTable;
|
$this->enquiryTable = $enquiryTable;
|
||||||
$this->vars['cats'] = $this->catsTable->findAll();
|
$this->vars['cats'] = $this->catsTable->findAll();
|
||||||
}
|
}
|
||||||
|
//Homepage
|
||||||
public function home() {
|
public function home() { //Route: jobs.v.je/jobs/home
|
||||||
$this->vars['jobs'] = $this->jobsTable->find(["closingDate", 'archived'], ['value0' => date('y-m-d'), 'value1' => 'n'], ['>', '='], "DESC", "closingDate");
|
$this->vars['jobs'] = $this->jobsTable->find(["closingDate", 'archived'], ['value0' => date('y-m-d'), 'value1' => 'n'], ['>', '='], "DESC", "closingDate");
|
||||||
return ['template' => 'home.html.php',
|
return ['template' => 'home.html.php',
|
||||||
'title' => 'Jo\'s Jobs- Home',
|
'title' => 'Jo\'s Jobs- Home',
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Category pages
|
||||||
public function category() {
|
public function category() { //Route: jobs.v.je/jobs/category
|
||||||
$cat = $this->catsTable->find(['name'], ['value0' => $_GET['page']]);
|
$cat = $this->catsTable->find(['name'], ['value0' => $_GET['page']]);
|
||||||
if ($cat == null) {
|
if ($cat == null) {
|
||||||
return $this->notFound();
|
return $this->notFound();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isset($_GET['filter'])) {
|
if (isset($_GET['filter'])) { //location filter for jobs
|
||||||
$columns = ['categoryId', "location", 'closingDate', 'archived'];
|
$columns = ['categoryId', "location", 'closingDate', 'archived'];
|
||||||
$values = ['value0' => $cat[0]->id,
|
$values = ['value0' => $cat[0]->id,
|
||||||
'value1' => $_GET['filter'],
|
'value1' => $_GET['filter'],
|
||||||
|
|
@ -50,22 +50,22 @@ class Jobs {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//About page
|
||||||
public function about() {
|
public function about() { //Route: jobs.v.je/jobs/about
|
||||||
return ['template' => 'about.html.php',
|
return ['template' => 'about.html.php',
|
||||||
'title' => 'Jo\'s Jobs- About us',
|
'title' => 'Jo\'s Jobs- About us',
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Contact page
|
||||||
public function contact() {
|
public function contact() { //Route: jobs.v.je/jobs/contact
|
||||||
return ['template' => 'contact.html.php',
|
return ['template' => 'contact.html.php',
|
||||||
'title' => 'Jo\'s Jobs- Contact',
|
'title' => 'Jo\'s Jobs- Contact',
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Contact page POST
|
||||||
public function contactSubmit() {
|
public function contactSubmit() { //Route: jobs.v.je/jobs/contact
|
||||||
$record = [
|
$record = [
|
||||||
'name' => $_POST['name'],
|
'name' => $_POST['name'],
|
||||||
'email' => $_POST['email'],
|
'email' => $_POST['email'],
|
||||||
|
|
@ -78,24 +78,24 @@ class Jobs {
|
||||||
'title' => 'Jo\'s Jobs- Enquiry Sent',
|
'title' => 'Jo\'s Jobs- Enquiry Sent',
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
}
|
}
|
||||||
|
//404 page
|
||||||
public function notFound() {
|
public function notFound() { //Route: jobs.v.je/jobs/notFound
|
||||||
$this->vars['response'] = 'The page you have requested has not been found';
|
$this->vars['response'] = 'The page you have requested has not been found';
|
||||||
return ['template' => 'response.html.php',
|
return ['template' => 'response.html.php',
|
||||||
'title' => 'Jo\'s Jobs- 404 Not Found',
|
'title' => 'Jo\'s Jobs- 404 Not Found',
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Job Application page
|
||||||
public function apply() {
|
public function apply() { //Route: jobs.v.je/jobs/apply
|
||||||
$this->vars['job'] = $this->jobsTable->find(['id'], ["value0" => $_GET['id']])[0];
|
$this->vars['job'] = $this->jobsTable->find(['id'], ["value0" => $_GET['id']])[0];
|
||||||
return ['template' => 'apply.html.php',
|
return ['template' => 'apply.html.php',
|
||||||
'title' => 'Jo\'s Jobs- Apply',
|
'title' => 'Jo\'s Jobs- Apply',
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//Job Application page POST
|
||||||
public function applySubmit() {
|
public function applySubmit() { //Route: jobs.v.je/jobs/apply
|
||||||
if ($_FILES['cv']['error'] == 0) {
|
if ($_FILES['cv']['error'] == 0) {
|
||||||
$parts = explode('.', $_FILES['cv']['name']);
|
$parts = explode('.', $_FILES['cv']['name']);
|
||||||
$extension = end($parts);
|
$extension = end($parts);
|
||||||
|
|
@ -125,8 +125,8 @@ class Jobs {
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//FAQ Page
|
||||||
public function faq() {
|
public function faq() { //Route: jobs.v.je/jobs/faq
|
||||||
return ['template' => 'construction.html.php',
|
return ['template' => 'construction.html.php',
|
||||||
'title' => 'Jo\'s Jobs- FAQ',
|
'title' => 'Jo\'s Jobs- FAQ',
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ class Portal {
|
||||||
$this->vars['cats'] = $this->catsTable->findAll();
|
$this->vars['cats'] = $this->catsTable->findAll();
|
||||||
$this->vars['table'] = 'job_table.html.php';
|
$this->vars['table'] = 'job_table.html.php';
|
||||||
}
|
}
|
||||||
|
//Portal homepage
|
||||||
public function home() {
|
public function home() { //Route: jobs.v.je/portal/
|
||||||
$this->vars['table'] = 'job_table.html.php';
|
$this->vars['table'] = 'job_table.html.php';
|
||||||
if (isset($_GET['filter'])) {
|
if (isset($_GET['filter'])) {
|
||||||
if ($_SESSION['userType'] == 'client') {
|
if ($_SESSION['userType'] == 'client') {
|
||||||
|
|
@ -40,9 +40,9 @@ class Portal {
|
||||||
'title' => 'Jo\'s Jobs- Jobs',
|
'title' => 'Jo\'s Jobs- Jobs',
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
}
|
}
|
||||||
|
//Portal homepage POST
|
||||||
public function homeSubmit() {
|
public function homeSubmit() { //Route: jobs.v.je/portal/
|
||||||
if ($_POST['submit'] == "List") {
|
if ($_POST['submit'] == "List") { //Relist archived job
|
||||||
$this->vars['job'] = $this->jobsTable->find(['id'], ['value0' => $_POST['job_id']])[0];
|
$this->vars['job'] = $this->jobsTable->find(['id'], ['value0' => $_POST['job_id']])[0];
|
||||||
$this->vars['archive'] = true;
|
$this->vars['archive'] = true;
|
||||||
$this->vars['update'] = true;
|
$this->vars['update'] = true;
|
||||||
|
|
@ -51,7 +51,7 @@ class Portal {
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isset($_POST['job_id'])) {
|
if (isset($_POST['job_id'])) { //archive job
|
||||||
$record = [
|
$record = [
|
||||||
'id' => $_POST['job_id'],
|
'id' => $_POST['job_id'],
|
||||||
'archived' => 'y'
|
'archived' => 'y'
|
||||||
|
|
@ -59,7 +59,7 @@ class Portal {
|
||||||
$this->jobsTable->save($record);
|
$this->jobsTable->save($record);
|
||||||
return $this->home();
|
return $this->home();
|
||||||
}
|
}
|
||||||
if (isset($_POST['cat_id'])) {
|
if (isset($_POST['cat_id'])) { //delete category
|
||||||
$this->catsTable->delete("id", $_POST['cat_id']);
|
$this->catsTable->delete("id", $_POST['cat_id']);
|
||||||
$jobs = $this->jobsTable->find(['categoryId'], ['value0' => $_POST['cat_id']]);
|
$jobs = $this->jobsTable->find(['categoryId'], ['value0' => $_POST['cat_id']]);
|
||||||
foreach ($jobs as $job) {
|
foreach ($jobs as $job) {
|
||||||
|
|
@ -67,7 +67,7 @@ class Portal {
|
||||||
}
|
}
|
||||||
return $this->categories();
|
return $this->categories();
|
||||||
}
|
}
|
||||||
if (isset($_POST['user_id'])) {
|
if (isset($_POST['user_id'])) { //delete user
|
||||||
if($_POST['user_type'] == 'client') {
|
if($_POST['user_type'] == 'client') {
|
||||||
$this->usersTable->delete('id', $_POST['user_id']);
|
$this->usersTable->delete('id', $_POST['user_id']);
|
||||||
$jobs = $this->jobsTable->find(['clientId'], ['value0' => $_POST['user_id']]);
|
$jobs = $this->jobsTable->find(['clientId'], ['value0' => $_POST['user_id']]);
|
||||||
|
|
@ -79,8 +79,8 @@ class Portal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Categories Portal page
|
||||||
public function categories() {
|
public function categories() { //Route: jobs.v.je/portal/categories
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
$this->vars['table'] = 'category_table.html.php';
|
$this->vars['table'] = 'category_table.html.php';
|
||||||
$this->vars['cats'] = $this->catsTable->findAll();
|
$this->vars['cats'] = $this->catsTable->findAll();
|
||||||
|
|
@ -89,8 +89,8 @@ class Portal {
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Applicants Portal page
|
||||||
public function applicants() {
|
public function applicants() { //Route: jobs.v.je/portal/applicants
|
||||||
$job = $this->jobsTable->find(['id'], ['value0' => $_GET['job_id']])[0];
|
$job = $this->jobsTable->find(['id'], ['value0' => $_GET['job_id']])[0];
|
||||||
$this->vars['table'] = 'applicant_table.html.php';
|
$this->vars['table'] = 'applicant_table.html.php';
|
||||||
$this->vars['apps'] = $job->getApps();
|
$this->vars['apps'] = $job->getApps();
|
||||||
|
|
@ -99,8 +99,8 @@ class Portal {
|
||||||
'title' => 'Jo\'s Jobs- Applicants',
|
'title' => 'Jo\'s Jobs- Applicants',
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
}
|
}
|
||||||
|
//Users Portal page
|
||||||
public function users() {
|
public function users() { //Route: jobs.v.je/portal/users
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
$this->vars['table'] = 'user_table.html.php';
|
$this->vars['table'] = 'user_table.html.php';
|
||||||
$this->vars['users'] = $this->usersTable->findAll();
|
$this->vars['users'] = $this->usersTable->findAll();
|
||||||
|
|
@ -110,8 +110,8 @@ class Portal {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Enquiries Portal page
|
||||||
public function enquiries() {
|
public function enquiries() { //Route: jobs.v.je/portal/enquiries
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
$this->vars['table'] = 'enquiry_table.html.php';
|
$this->vars['table'] = 'enquiry_table.html.php';
|
||||||
$this->vars['enqs'] = $this->enquiryTable->findAll();
|
$this->vars['enqs'] = $this->enquiryTable->findAll();
|
||||||
|
|
@ -121,8 +121,8 @@ class Portal {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Enquiries Portal page POST
|
||||||
public function enquiriesSubmit() {
|
public function enquiriesSubmit() { //Route: jobs.v.je/portal/enquiries
|
||||||
$record = [
|
$record = [
|
||||||
'id' => $_POST['enq_id'],
|
'id' => $_POST['enq_id'],
|
||||||
'completed' => 'y',
|
'completed' => 'y',
|
||||||
|
|
@ -131,14 +131,14 @@ class Portal {
|
||||||
$this->enquiryTable->save($record);
|
$this->enquiryTable->save($record);
|
||||||
$this->enquiries();
|
$this->enquiries();
|
||||||
}
|
}
|
||||||
|
//Edit User Portal page
|
||||||
public function addUser() {
|
public function addUser() { //Route: jobs.v.je/portal/addUser
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
if (isset($_GET['user_id'])) {
|
if (isset($_GET['user_id'])) { //Update user
|
||||||
$this->vars['user'] = $this->usersTable->find(['id'], ['value0' => $_GET['user_id']])[0];
|
$this->vars['user'] = $this->usersTable->find(['id'], ['value0' => $_GET['user_id']])[0];
|
||||||
$this->vars['update'] = true;
|
$this->vars['update'] = true;
|
||||||
}
|
}
|
||||||
else {
|
else { //Create user
|
||||||
$this->vars['update'] = false;
|
$this->vars['update'] = false;
|
||||||
}
|
}
|
||||||
return ['template' => 'user_add.html.php',
|
return ['template' => 'user_add.html.php',
|
||||||
|
|
@ -147,7 +147,7 @@ class Portal {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Edit User Portal page POST
|
||||||
public function addUserSubmit() {
|
public function addUserSubmit() {
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
if($_POST['password'] != "") {
|
if($_POST['password'] != "") {
|
||||||
|
|
@ -172,14 +172,14 @@ class Portal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Edit Job Portal page
|
||||||
public function addJob() {
|
public function addJob() { //Route: jobs.v.je/portal/addJob
|
||||||
if (isset($_GET['job_id'])) {
|
if (isset($_GET['job_id'])) { //Update Job
|
||||||
$this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['job_id']])[0];
|
$this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['job_id']])[0];
|
||||||
$this->vars['archive'] = false;
|
$this->vars['archive'] = false;
|
||||||
$this->vars['update'] = true;
|
$this->vars['update'] = true;
|
||||||
}
|
}
|
||||||
else {
|
else { //Create Job
|
||||||
$this->vars['archive'] = false;
|
$this->vars['archive'] = false;
|
||||||
$this->vars['update'] = false;
|
$this->vars['update'] = false;
|
||||||
}
|
}
|
||||||
|
|
@ -188,8 +188,8 @@ class Portal {
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Edit Job page POST
|
||||||
public function addJobSubmit() {
|
public function addJobSubmit() { //Route: jobs.v.je/portal/addJob
|
||||||
if ($this->catsTable->find(['name'], ['value0' => $_POST['categoryName']]) != 0) {
|
if ($this->catsTable->find(['name'], ['value0' => $_POST['categoryName']]) != 0) {
|
||||||
$record = [
|
$record = [
|
||||||
'title' => $_POST['title'],
|
'title' => $_POST['title'],
|
||||||
|
|
@ -221,8 +221,8 @@ class Portal {
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Edit Category page
|
||||||
public function addCategory() {
|
public function addCategory() { //Route: jobs.v.je/portal/addCategory
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
if (isset($_GET['cat_id'])) {
|
if (isset($_GET['cat_id'])) {
|
||||||
$this->vars['cat'] = $this->catsTable->find(["id"], ['value0' => $_GET['cat_id']])[0];
|
$this->vars['cat'] = $this->catsTable->find(["id"], ['value0' => $_GET['cat_id']])[0];
|
||||||
|
|
@ -237,8 +237,8 @@ class Portal {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Edit Category page POST
|
||||||
public function addCategorySubmit() {
|
public function addCategorySubmit() { //Route: jobs.v.je/portal/addCategory
|
||||||
if ($_SESSION['userType'] == 'admin') {
|
if ($_SESSION['userType'] == 'admin') {
|
||||||
if ($_POST['submit'] == 'Create') {
|
if ($_POST['submit'] == 'Create') {
|
||||||
if (count($this->catsTable->find(['name'], ['value0' => $_POST['name']])) > 0) {
|
if (count($this->catsTable->find(['name'], ['value0' => $_POST['name']])) > 0) {
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ class User {
|
||||||
$this->vars['cats'] = $this->catsTable->findAll();
|
$this->vars['cats'] = $this->catsTable->findAll();
|
||||||
$this->vars['response'] = '';
|
$this->vars['response'] = '';
|
||||||
}
|
}
|
||||||
|
//Login page
|
||||||
public function login() {
|
public function login() { //Route: jobs.v.je/user/login
|
||||||
return ['template' => 'login.html.php',
|
return ['template' => 'login.html.php',
|
||||||
'title' => 'Jo\'s Jobs- Login',
|
'title' => 'Jo\'s Jobs- Login',
|
||||||
'vars' => $this->vars];
|
'vars' => $this->vars];
|
||||||
}
|
}
|
||||||
|
//Login page POST
|
||||||
public function loginSubmit() {
|
public function loginSubmit() { //Route: jobs.v.je/user/login
|
||||||
if ($_POST['username'] != '' && $_POST['password'] != '') {
|
if ($_POST['username'] != '' && $_POST['password'] != '') {
|
||||||
$user = $this->usersTable->find(["username"], ['value0' => $_POST['username']]);
|
$user = $this->usersTable->find(["username"], ['value0' => $_POST['username']]);
|
||||||
if (password_verify($_POST['password'], $user[0]->password)) {
|
if (password_verify($_POST['password'], $user[0]->password)) {
|
||||||
|
|
@ -49,8 +49,8 @@ class User {
|
||||||
'vars' => $this->vars
|
'vars' => $this->vars
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
//Logout page
|
||||||
public function logout() {
|
public function logout() { //Route: jobs.v.je/user/logout
|
||||||
unset($_SESSION['loggedin']);
|
unset($_SESSION['loggedin']);
|
||||||
unset($_SESSION['userType']);
|
unset($_SESSION['userType']);
|
||||||
$this->vars['response'] = 'Logged Out Successfully';
|
$this->vars['response'] = 'Logged Out Successfully';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start(); //make sure session is started
|
||||||
require '../autoload.php';
|
require '../autoload.php'; //include autoload
|
||||||
$routes = new \jobs\Routes();
|
$routes = new \jobs\Routes(); //get routes
|
||||||
$entryPoint = new \CSY2028\EntryPoint($routes);
|
$entryPoint = new \CSY2028\EntryPoint($routes); //get entrypoint
|
||||||
$entryPoint->run();
|
$entryPoint->run(); //start entrypoint
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue