From dd6c8d1cab397e3fc125392cefc1c9588e21b973 Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Sun, 5 Feb 2023 23:04:45 +0000 Subject: [PATCH] finished --- jobs/controllers/Portal.php | 36 +++++++++++++++++++----------------- phpunit.xml | 8 ++++++++ templates/job_add.html.php | 11 +++++------ templates/nav.html.php | 10 +++++----- templates/user_add.html.php | 2 +- tests/testTest.php | 6 ++++++ 6 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 phpunit.xml create mode 100644 tests/testTest.php diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index d79bdd5..5487a9b 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -150,24 +150,26 @@ class Portal { public function addUserSubmit() { if ($_SESSION['userType'] == 'admin') { - $record = [ - 'username' => $_POST['username'], - 'password' => password_hash($_POST['password'], PASSWORD_DEFAULT), - 'userType' => $_POST['type'] - ]; - if ($_POST['submit'] == 'Update') { - $record['id'] = $_POST['user_id']; - $this->vars['response'] = 'User Updated Successfully'; + if($_POST['password'] != "") { + $record = [ + 'username' => $_POST['username'], + 'password' => password_hash($_POST['password'], PASSWORD_DEFAULT), + 'userType' => $_POST['type'] + ]; + if ($_POST['submit'] == 'Update') { + $record['id'] = $_POST['user_id']; + $this->vars['response'] = 'User Updated Successfully'; + } + else { + $this->vars['response'] = 'User Created Successfully'; + } + $this->usersTable->save($record); + return [ + 'template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Edit user', + 'vars' => $this->vars + ]; } - else { - $this->vars['response'] = 'User Created Successfully'; - } - $this->usersTable->save($record); - return [ - 'template' => 'response.html.php', - 'title' => 'Jo\'s Jobs- Edit user', - 'vars' => $this->vars - ]; } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..57f38a9 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,8 @@ + + + + + tests + + + \ No newline at end of file diff --git a/templates/job_add.html.php b/templates/job_add.html.php index 9554433..80b9ec6 100644 --- a/templates/job_add.html.php +++ b/templates/job_add.html.php @@ -1,12 +1,7 @@
- - - + - @@ -22,8 +17,12 @@ + + + diff --git a/templates/nav.html.php b/templates/nav.html.php index 25eef58..a7e34b8 100644 --- a/templates/nav.html.php +++ b/templates/nav.html.php @@ -8,12 +8,12 @@
  • Admin Portal
  • -
  • Client Portal
  • - +
  • Logout
  • - -
  • Login
  • + +
  • Login
  • \ No newline at end of file diff --git a/templates/user_add.html.php b/templates/user_add.html.php index 895d521..5e9e7d7 100644 --- a/templates/user_add.html.php +++ b/templates/user_add.html.php @@ -4,7 +4,7 @@ - + diff --git a/tests/testTest.php b/tests/testTest.php new file mode 100644 index 0000000..e4ae6e1 --- /dev/null +++ b/tests/testTest.php @@ -0,0 +1,6 @@ + \ No newline at end of file