-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsers.php
78 lines (64 loc) · 2.25 KB
/
Users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
require_once "MongoPOO.php";
class Users extends MongoPOO {
static public $usersToAdd = [
['name' => 'Administrator', 'password' => 'admin123', 'role' => 'admin'],
['name' => 'Tony', 'password' => 'tony123', 'role' => 'user'],
['name' => 'Lucie', 'password' => 'lucie23', 'role' => 'user'],
['name' => 'Louis', 'password' => 'louis123', 'role' => 'user']
];
public static $nbReservations = 0;
/**
* Get the user logged
*/
public function getUser() {
return $_SESSION['username'];
}
public static function userNbReservations() {
self::$nbReservations = self::$nbReservations + 1;
}
/**
* Display every user
*/
public function displayUsers($dbName, $collectionSpells, $filter = null) {
$query = $this->initQuery($dbName, $collectionSpells, $filter);
echo "<table>
<thead>
<tr>
<th>Nom</th>
<th>Rôle</th>
<th>Suppression</th>
</tr>
</thead>
<tbody>";
foreach ($query as $key => $row) {
if(isset($row->name)) {
$name = $row->name;
}
if(isset($row->role)) {
$role = $row->role;
}
$items[] = $name;
if($_SERVER['REQUEST_METHOD'] === "POST" and isset($_POST)) {
foreach($items as $item) {
var_dump($item);
if(array_key_exists($item, $_POST)) {
// var_dump($_POST);
// $this->deleteDatas(self::$dbName, self::$collectionUsers, [['name' => $name]] );
// $items[] = $name;
} else {
}
}
}
echo "<tr>";
echo "<td>" . $name ."</td>";
echo "<td>" . $role ."</td>";
echo "<td>
<form action='listUsers.php' method='post'>
<input type='submit' name='".$name."' value='Supprimer' />
</form>
</td>";
echo "</tr>";
}
}
}