-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveAdmin.php
More file actions
46 lines (36 loc) · 1.27 KB
/
RemoveAdmin.php
File metadata and controls
46 lines (36 loc) · 1.27 KB
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
<?php
require_once 'Include/Load.php';
$session = App::getSession();
$link = App::getDatabase();
$superAdmin = App::getSuperAdmin();
$admin = App::getAdmin();
$validator = App::getValidator();
$admin->restrict();
if (!$admin->has('id') && !$superAdmin->has('answer')){
App::redirect('Posts.php');
}
if ($admin->has('id')) {
if (str_contains($session->getKey('user_infos')->status, 'admin')) {
$result = $link->query('SELECT * FROM users WHERE id = :id', [
'id' => App::get('id')
])->fetch();
if ($admin->removeAdmin($result)){
$session->setFlash('success', 'This User is not an Administrator of this Website anymore');
} else {
$session->setFlash('success', 'The Boss Approval in order to remove this User from the Administrators is awaited');
}
}
}
if ($superAdmin->has('answer')){
$answer = App::get('answer');
if (!$superAdmin->has('id')){
App::redirect('Posts.php');
}
$result = $link->query('SELECT * FROM users WHERE id = :id', [
'id' => App::get('id')
])->fetch();
if ($superAdmin->approveAdminRemoval($result, $answer)){
$session->setFlash('success', 'This User is not an Administrator of this Website anymore');
}
}
App::redirect('Posts.php');