finished
This commit is contained in:
parent
1f487fe45e
commit
dd6c8d1cab
|
|
@ -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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit>
|
||||
<testsuites>
|
||||
<testsuite name="tests">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 } ?>
|
||||
<?php } ?>
|
||||
<li><a href="/user/logout">Logout</a></li>
|
||||
<?php }
|
||||
else {?>
|
||||
<li><a href="/user/login">Login</a></li>
|
||||
<?php }
|
||||
else {?>
|
||||
<li><a href="/user/login">Login</a></li>
|
||||
<?php } ?>
|
||||
|
|
@ -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?>" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
class DatabaseTableTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testFindColumnsValues() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue