-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddAdmin.php
59 lines (45 loc) · 1.61 KB
/
AddAdmin.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
<?php
require_once 'Include/Load.php';
$session = App::getSession();
$link = App::getDatabase();
$superAdmin = App::getSuperAdmin();
$admin = App::getAdmin();
$user = App::getUser();
$admin->restrict();
if (!$admin->has('id') && !$superAdmin->has('answer') && !$user->has('value')){
App::redirect('Posts.php');
}
if ($admin->has('id')) {
$result = $link->query('SELECT * FROM users WHERE id = :id', [
'id' => App::get('id')
])->fetch();
if (str_contains($session->getKey('user_infos')->status, 'admin')) {
if ($admin->sendAdminRequest($result)) {
$session->setFlash('success', 'An Admin Request has been successfully sent to the User');
} else {
$session->setFlash('success', 'The Boss Approval for the Admin Request is awaited');
}
}
}
if ($superAdmin->has('answer')){
$answer = App::get('answer');
if ($superAdmin->has('id')){
$result = $link->query('SELECT * FROM users WHERE id = :id', [
'id' => App::get('id')
])->fetch();
if($superAdmin->superAdminApproval($result, $answer)){
$session->setFlash('success', 'An Admin Request has been successfully sent to the User');
}
} else {
App::redirect('Posts.php');
}
}
if ($user->has('value')){
$result = $link->query('SELECT * FROM users WHERE id = :id', [
'id' => $session->getKey('user_infos')->id
])->fetch();
if ($user->confirmAdminRequest($result, App::get('value'))){
$session->setFlash("success", "Congratulations! You're now an Administrator of this Website");
}
}
App::redirect('Posts.php');