-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
360 lines (308 loc) · 9.5 KB
/
profile.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?php
$thisFileName = basename(__FILE__);
require_once (dirname(__FILE__) . '/Pages/header.php');
require_once (dirname(__FILE__) . '/Classes/Recours.php');
if ($_SESSION['TU'] == 'Etudiant')
{
require_once (dirname(__FILE__) . '/Classes/Enseignant.php');
// For generating recours info //
$rec = new recours($id);
$rec = $rec->getAllRecoursET();
// Pour generer le nombre totale des recours soumis par cette etudiant //
$nbrRecours = count($rec);
// Pour la table CRUD des recours! //
foreach ($rec as $key => $recours)
if ($recours['statusET'] == 'show')
$recToShow[$key] = $recours;
if (isset($_GET['view']))
{
$idrec = $_GET['view'];
if (checkNum($idrec))
{
$_SESSION['message'] = '<b>Accessing that page is not permitted!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else
{
$viewRec = new recours($idrec);
$viewRec = $viewRec->getRecours();
if (empty($viewRec))
{
$_SESSION['message'] = '<b>You have no permission to view this page!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else if (!strcmp($viewRec['statusET'], 'hide'))
{
$_SESSION['message'] = '<b>Recours has been deleted by you!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else
{
$ENSV = new enseignant($viewRec['idens']);
$ENSV = $ENSV->getInfo();
}
}
}
if (isset($_GET['update']))
{
$idrec = $_GET['update'];
if (checkNum($idrec))
{
$_SESSION['message'] = '<b>Accessing that page is not permitted!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
else
{
$update = new recours($idrec);
$update = $update->getRecours();
if (empty($update))
{
$_SESSION['message'] = '<b>You have no permission to view this page!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
else if ($_SESSION['id'] != $update['idet'])
{
$_SESSION['message'] = '<b>You have no permission!</b>';
$_SESSION['type'] = "danger";
header("Location: ../profile.php?errorupdate");
unset($_GET['update']);
}
else if (!strcmp($update['statusET'], 'hide'))
{
$_SESSION['message'] = '<b>You have deleted this recours, you cannot modify it!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
else if (!strcmp($update['status'], 'Validé'))
{
$_SESSION['message'] = '<b>Recours already validated, you cannot modify it!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
else if (!strcmp($update['status'], 'Refusé'))
{
$_SESSION['message'] = '<b>Recours already refused, you cannot modify it!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
else
{
$module = $update['module'];
$typeE = $update['typeE'];
$emailens = $update['emailens'];
$desc = $update['description'];
}
}
}
}
else if ($_SESSION['TU'] == 'Enseignant')
{
require_once (dirname(__FILE__) . '/Classes/Etudiant.php');
// For generating recours info //
$rec = new recours($id);
$rec = $rec->getAllRecoursENS();
// Pour generer le nombre totale des recours soumis par cette etudiant //
$nbrRecours = count($rec);
// Pour la table CRUD des recours! //
foreach ($rec as $key => $recours)
if ($recours['statusENS'] == 'show')
{
if ($recours['status'] == 'En Cours')
$recNonTreated[$key] = $recours;
elseif ($recours['status'] == 'Validé')
$recValidated[$key] = $recours;
elseif ($recours['status'] == 'Refusé')
$recRefused[$key] = $recours;
}
// Viewing the recours! //
if (isset($_GET['view']))
{
$idrec = $_GET['view'];
if (checkNum($idrec))
{
$_SESSION['message'] = '<b>Accessing that page is not permitted!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else
{
$viewRec = new recours($idrec);
$viewRec = $viewRec->getRecours();
if (empty($viewRec))
{
$_SESSION['message'] = '<b>You have no permission to view this page!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else if (!strcmp($viewRec['statusENS'], 'hide'))
{
$_SESSION['message'] = '<b>Recours has been deleted by you or the student before refusing or validating!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else
{
$ETV = new etudiant($viewRec['idet']);
$ETV = $ETV->getInfo();
}
}
}
}
else if ($_SESSION['TU'] == 'Administrateur')
{
require_once (dirname(__FILE__) . '/Classes/Visitor.php');
require_once (dirname(__FILE__) . '/Classes/Etudiant.php');
require_once (dirname(__FILE__) . '/Classes/Enseignant.php');
// For generating users info //
$allUsers = new visitor($id);
$allUsers = $allUsers->getUsers();
// Pour la table CRUD des utilisateurs! //
foreach ($allUsers as $key => $user)
if ($user['username'] != 'dummyUser' && !empty($user['type']) && $user['type'] != 'Administrateur' && $user['auth'] != 'Unauthorized')
$users[$key] = $user;
if (isset($_GET['view']))
{
$iduser = $_GET['view'];
if (checkNum($iduser))
{
$_SESSION['message'] = '<b>Accessing that page is not permitted!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
else
{
// Fetching user info! //
foreach ($users as $user)
if ($iduser == $user['id'])
{
if ($user['type'] == 'Etudiant')
$viewUser = new etudiant($iduser);
elseif ($user['type'] == 'Enseignant')
$viewUser = new enseignant($iduser);
}
if (isset($viewUser))
$viewUser = $viewUser->getInfo();
// Verifying user info! //
if (!isset($viewUser) || empty($viewUser))
{
$_SESSION['message'] = '<b>You have no permission to view this page!</b>';
$_SESSION['type'] = "danger";
unset($_GET['view']);
}
}
}
if (isset($_GET['update']))
{
$iduser = $_GET['update'];
if (checkNum($iduser))
{
$_SESSION['message'] = '<b>Accessing that page is not permitted!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
else
{
// Fetching user info! //
foreach ($users as $user)
if ($iduser == $user['id'])
{
if ($user['type'] == 'Etudiant')
{
$type = 'Etudiant';
$viewUser = new etudiant($iduser);
}
elseif ($user['type'] == 'Enseignant')
{
$type = 'Enseignant';
$viewUser = new enseignant($iduser);
}
}
if (isset($viewUser))
$viewUser = $viewUser->getInfo();
// Verifying user info! //
if (!isset($viewUser) || empty($viewUser) || !isset($type))
{
$_SESSION['message'] = '<b>You have no permission to view this page!</b>';
$_SESSION['type'] = "danger";
unset($_GET['update']);
}
}
}
}
?>
<!-- Main content -->
<section class="content mt-3">
<div class="container-fluid">
<!-- Session Message -->
<?php
if (isset($_SESSION['message'])): ?>
<div class="alert alert-<?=$_SESSION['type']?> alert-dismissible fade show" role="alert">
<?php
if (!strcmp($_SESSION['type'], 'danger')) echo '<i class="icon fas fa-ban"></i>' . $_SESSION['message'];
if (!strcmp($_SESSION['type'], 'warning')) echo '<i class="icon fas fa-exclamation-triangle"></i>' . $_SESSION['message'];
if (!strcmp($_SESSION['type'], 'success')) echo '<i class="icon fas fa-check"></i>' . $_SESSION['message'];
unset($_SESSION['message']);
else: ?>
<div class="alert alert-<?=$_SESSION['type']?> alert-dismissible fade show d-none" role="alert">
<?php
endif;
?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<!-- /Session Message -->
<!-- Redirecting not fully registered users! -->
<?php if (!isset($_SESSION['TU'])): ?>
<!-- Default box -->
<div class="card card-warning mt-3">
<div class="card-header">
<h3 class="card-title"><b>Registration</b></h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
<i class="fas fa-minus"></i>
</button>
<button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="card-body">
You have to continue your full registration to access this page with it's extra functionalies!
</div>
<!-- /.card-body -->
<div class="card-footer">
<a class="btn btn-warning btn-outline" href="./registerFULL.php">
Register
</a>
</div>
<!-- /.card-footer-->
</div>
<!-- /.card -->
<?php endif; ?>
<!-- ET -->
<?php if ($_SESSION['TU'] == "Etudiant")
require_once ('./Pages/profileET.php');
?>
<!-- /ET -->
<!-- ENS -->
<?php if ($_SESSION['TU'] == "Enseignant")
require_once ('./Pages/profileENS.php');
?>
<!-- /ENS -->
<!-- ADM -->
<?php if ($_SESSION['TU'] == "Administrateur")
require_once ('./Pages/profileADM.php');
?>
<!-- /ADM -->
</div><!-- /.container-fluid -->
</section>
<!-- /.content -->
<?php
require './Pages/footer.php';
?>