-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.php
139 lines (122 loc) · 5.25 KB
/
delete.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
$xml = simplexml_load_file('ESTS1.xml');
if(isset($_POST["permission_role_id"])){
$permission_role_id = $_POST['permission_role_id'];
list($id_Permissions, $id_Roles) = explode(".", (string)$permission_role_id);
foreach ($xml->roles_permissions->role_permission as $role_permission) {
// if the login of the current user matches the login of the user to delete
if ((string)$role_permission['id_Permissions'] == (string)$id_Permissions && (string)$role_permission['id_Roles'] == (string)$id_Roles) {
// remove the user from the XML file
unset($role_permission[0]);
break;
}
}
// save the modified XML file
$xml->asXML('./ESTS1.xml');
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load('ESTS1.xml');
$dom->save('ESTS1.xml');
}
// ----------------------------------------- DELETE PERMISSION and PERMISSION_ROLE---------------------------------------------------
if(isset($_POST["permission_id"])){
$permission_id = $_POST['permission_id'];
foreach ($xml->Permissions->permission as $permission) {
// if the login of the current user matches the login of the user to delete
if ((string)$permission['id'] == (string)$permission_id) {
// remove the user from the XML file
unset($permission[0]);
$xml->asXML('./ESTS1.xml');
break;
}
}
$toRemove = $xml->xpath("//role_permission[@id_Permissions=$permission_id]");
foreach ($toRemove as $remove) {
unset($remove[0]);
$xml->asXML('./ESTS1.xml');
}
// save the modified XML file
$xml->asXML('./ESTS1.xml');
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load('ESTS1.xml');
$dom->save('ESTS1.xml');
}
// ----------------------------------------- DELETE MATIERE and USER_MATIERE---------------------------------------------------
if(isset($_POST["matiere_id"])){
$matiere_id = $_POST['matiere_id'];
foreach ($xml->Matieres->matiere as $matiere) {
// if the login of the current user matches the login of the user to delete
if ((string)$matiere['id'] == (string)$matiere_id) {
// remove the user from the XML file
unset($matiere[0]);
break;
}
}
foreach ($xml->access->user_matiere as $user_matiere) {
// if the login of the current user matches the login of the user to delete
if ((string)$user_matiere['id_Matieres'] == (string)$matiere_id) {
// remove the user from the XML file
unset($user_matiere[0]);
break;
}
}
// save the modified XML file
$xml->asXML('./ESTS1.xml');
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load('ESTS1.xml');
$dom->save('ESTS1.xml');
}
// ----------------------------------------- DELETE USER_MATIERE---------------------------------------------------
if(isset($_POST["matiere_user"])){
$matiere_post = $_POST['matiere_user'];
foreach ($xml->access->user_matiere as $user_matiere) {
// if the login of the current user matches the login of the user to delete
if ((string)$user_matiere['id_Matieres'] == (string)$matiere_post) {
// remove the user from the XML file
unset($user_matiere[0]);
break;
}
}
// save the modified XML file
$xml->asXML('./ESTS1.xml');
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load('ESTS1.xml');
$dom->save('ESTS1.xml');
}
// ----------------------------------------- DELETE USER AND USER_MATIERE---------------------------------------------------
if(isset($_POST["login"])){
$login = $_POST['login'];
// iterate through the users in the XML file
foreach ($xml->Users->user as $user) {
// if the login of the current user matches the login of the user to delete
if ($user->login == $login) {
// remove the user from the XML file
unset($user[0]);
break;
}
}
$xml->asXML('./ESTS1.xml');
foreach ($xml->access->user_matiere as $matiere) {
// if the login of the current user matches the login of the user to delete
if ((string)$matiere['login_user'] == (string)$login) {
// remove the user from the XML file
unset($matiere[0]);
// break;
}
}
// save the modified XML file
$xml->asXML('./ESTS1.xml');
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load('ESTS1.xml');
$dom->save('ESTS1.xml');
}
?>