This commit is contained in:
Joshua Perry 2023-02-05 23:04:45 +00:00
parent 1f487fe45e
commit dd6c8d1cab
6 changed files with 44 additions and 29 deletions

View File

@ -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
];
}
}

8
phpunit.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<phpunit>
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -1,12 +1,7 @@
<main class="home">
<form method="post" action="/portal/addJob">
<?php if ($archive) { ?>
<input type="hidden" name="archived" value="n"/>
<?php }
else { ?>
<?php if ($update) {?>
<input type="hidden" name="archived" value="<?=$job->archived?>"/>
<?php }
if ($update) {?>
<label>Enter Job Title</label>
<input type="text" name="title" value="<?=$job->title?>"/>
<label>Enter Job Description</label>
@ -22,8 +17,12 @@
<input type="hidden" name="client_id" value="<?=$job->clientId?>" />
<input type="hidden" name="jobId" value="<?=$job->id?>"/>
<input type="submit" name="submit" value="Update"/>
<?php }
else if ($archive) { ?>
<input type="hidden" name="archived" value="n"/>
<?php }
else { ?>
<input type="hidden" name="archived" value="n"/>
<label>Enter Job Title</label>
<input type="text" name="title"/>
<label>Enter Job Description</label>

View File

@ -8,12 +8,12 @@
<?php if (isset($_SESSION['loggedin'])) {
if ($_SESSION['userType'] == 'admin') {?>
<li><a href="/portal">Admin Portal</a></li>
<?php }
<?php }
else if ($_SESSION['userType'] == 'client') {?>
<li><a href="/portal">Client Portal</a></li>
<?php } ?>
<li><a href="/user/logout">Logout</a></li>
<?php }
else {?>
<li><a href="/user/login">Login</a></li>
<?php } ?>
<li><a href="/user/logout">Logout</a></li>
<?php }
else {?>
<li><a href="/user/login">Login</a></li>
<?php } ?>

View File

@ -4,7 +4,7 @@
<label>Enter Username</label>
<input type="username" name="username" value="<?=$user->username?>"/>
<label>Enter Password</label>
<input type="password" name="password" value="<?=$user->password?>"/>
<input type="password" name="password" value=""/>
<label>Enter User Type</label>
<input type="text" name="type" value="<?=$user->userType?>"/>
<input type="hidden" name="user_id" value="<?=$user->id?>" />

6
tests/testTest.php Normal file
View File

@ -0,0 +1,6 @@
<?php
class DatabaseTableTest extends \PHPUnit\Framework\TestCase {
public function testFindColumnsValues() {
}
}
?>