forked from Denimon26/InventorySystem_PHP_MongoDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_group.php
41 lines (33 loc) · 1.28 KB
/
delete_group.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
<?php
require_once('includes/load.php');
require 'vendor/autoload.php';
use MongoDB\Client;
// Checkin What level user has permission to view this page
page_require_level(1);
function page_require_level($required_level) {
$uri = 'mongodb+srv://boladodenzel:denzelbolado@cluster0.9ahxb.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0';
$client = new Client($uri);
$database = $client->selectDatabase('inventory_system');
$admins = $database->selectCollection('admin');
$admin= $admins->findOne(['_id' => $_SESSION['user_id']]);
if (!isset($admin)) {
redirect('index.php', false);
}
if ($admin['user_level'] <= (int)$required_level) {
return true;
} else {
// If the user does not have permission, redirect to the home page
redirect('home.php', false);
}
}
?>
<?php
$uri = 'mongodb+srv://boladodenzel:denzelbolado@cluster0.9ahxb.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0';
$client = new Client($uri);
$database = $client->selectDatabase('inventory_system');
$groups = $database->selectCollection('group');
$group_id = $_GET['id'];
$group = $groups->deleteOne(['group_name' => $group_id]);
$session->msg("s","Group has been deleted.");
redirect('group.php');
?>