-
Notifications
You must be signed in to change notification settings - Fork 4
/
manage_sessions.inc.php
199 lines (180 loc) · 5.25 KB
/
manage_sessions.inc.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
<?php
require_once('manage_filters_and_sort.inc.php');
require_once('utils.inc.php');
function sessionArrays($force = false)
{
if($force || !isset($_SESSION['all_sessions']))
{
$sessions = array();
$ok = $_SESSION['filter_section'];
$sql = "SELECT * FROM ".sessions_db." WHERE `section`='". real_escape_string($ok)."' ORDER BY date DESC;";
$result = sql_request($sql);
date_default_timezone_set("Europe/Paris");
while ($row = mysqli_fetch_object($result))
$sessions[$row->id] = $row->id;
$_SESSION['all_sessions'] = $sessions;
}
return $_SESSION['all_sessions'];
}
function session_year($id_session)
{
//$sessions = sessionArrays();
// $nom_session = $sessions[$id_session];
//date_default_timezone_set('Europe/Paris');
// $result = date("Y", strtotime(substr($nom_session,strlen($nom_session) -4,4) ) );
$result = substr($id_session,strlen($id_session) -4,4);
return $result;
}
function session_lib($id_session)
{
//date_default_timezone_set('Europe/Paris');
// $result = date("Y", strtotime(substr($nom_session,strlen($nom_session) -4,4) ) );
$result = substr($id_session,0, strlen($id_session) -4);
return $result;
}
function current_session_id()
{
return getFilterValue('id_session');
}
function set_current_session_id($id)
{
unset($_SESSION['myconc']);
unset($_SESSION["rows_id"]);
unset($_SESSION["allconcours"]);
resetSessionFilters();
$_SESSION['filter_id_session'] = $id;
}
function check_current_session_exists()
{
$sessions = sessionArrays(true);
return current_session() != "Hors Session";
}
function get_session($id)
{
$sessions = sessionArrays();
$id = current_session_id();
if(isset($sessions[$id]))
return $sessions[$id];
else
return "Unknown session";
}
function current_session()
{
$sessions = sessionArrays();
$id = current_session_id();
if(isset($sessions[$id]))
return $sessions[$id];
else
return "Hors Session";
}
function is_current_session_concours()
{
if(current_session() == "")
return false;
$pref = substr(current_session(),0,4);
return ($pref == "Conc") || ($pref == "conc");
}
function is_current_session_delegation()
{
if(current_session() == "")
return false;
$pref = substr(current_session(),0,4);
return ($pref == "Dele") || ($pref == "dele");
}
function showSessions()
{
$finalResult = array();
date_default_timezone_set('Europe/Paris');
if(!isSuperuser())
$sql = "SELECT * FROM ".sessions_db." WHERE `section`='". real_escape_string($_SESSION['filter_section'])."' ORDER BY date DESC;";
else
$sql = "SELECT * FROM ".sessions_db." WHERE 1 ORDER BY date DESC;";
if($result= sql_request($sql))
while ($row = mysqli_fetch_object($result))
{
$finalResult[$row->id] = array( "id" => $row->id, "nom" => $row->nom, "date" => $row->date, "prettyprint" => $row->nom.' '.date("Y",strtotime($row->date)));
//echo $row->id."<br/>";
}
return $finalResult;
} ;
function deletePreRapports($id)
{
$sql = "UPDATE ".reports_db." SET ";
$sql .= "prerapport=\"\", prerapport2=\"\", prerapport3=\"\"";
$sql .= ",avis1=\"\", avis2=\"\", avis3=\"\"";
for($i = 0; $i <= 30; $i++)
$sql .= ",Generic".$i." =\"\"";
if(!isSuperUser())
$sql .= " WHERE id_session=\"".real_escape_string($id)."\"section=\"".real_escape_string($_SESSION['filter_section'])."\";";
else
$sql .= " WHERE id_session=\"".real_escape_string($id)."\"";
sql_request($sql);
}
function initConcours()
{
echo "<p>Suppression de toutes les fiches candidats<br/>";
$sql = "DELETE FROM ".people_db." WHERE concoursid!=\"\"";
sql_request($sql);
echo "<p>Suppression de tous les concours<br/>";
$sql = "DELETE FROM ".concours_db." WHERE 1";
sql_request($sql);
echo "Suppression de toutes les sessions concours</br>";
$sql = "DELETE FROM ".sessions_db." WHERE id LIKE \"%Concours%\";";
sql_request($sql);
echo "Suppression de toutes les candidatures</br>";
$sql = "DELETE FROM ".reports_db." WHERE id_session LIKE \"%Concours%\";";
sql_request($sql);
}
function deleteSession($id, $supprimerdossiers)
{
if(isSuperUser())
{
echo "<p>Suppression des sessions d'intitule ".$id."<br/>";
$sql = "DELETE FROM ".sessions_db." WHERE id='$id'";
sql_request($sql);
unset($_SESSION['all_sessions']);
if($supprimerdossiers)
{
echo "<p>Suppression des dossiers de la sessions ".$id."<br/>";
$sql = "DELETE FROM ".reports_db." WHERE id_session='$id'";
sql_request($sql);
}
/*
if(strpos($id,"Concours") !== FALSE)
{
}
*/
}
else
if (isSecretaire())
{
$sql = "DELETE FROM ".sessions_db." WHERE id='$id' AND section='".$_SESSION['filter_section']."';";
sql_request($sql);
unset($_SESSION['all_sessions']);
if($supprimerdossiers)
{
$sql = "DELETE FROM ".reports_db." WHERE id_session='$id' AND section='".$_SESSION['filter_section']."';";
sql_request($sql);
}
}
else
throw new Exception("Vous n'avez pas les droits suffisants pour effacer une session");
}
function get_all_sessions($section = "")
{
if($section != "")
$sql = "SELECT * FROM sessions WHERE `section`=\"".$section."\";";
else
$sql = "SELECT * FROM sessions WHERE 1;";
$result = sql_request($sql);
$sessions = array();
while($row = mysqli_fetch_object($result))
{
if($section != "")
$sessions[] = $row->id;
else
$sessions[$row->section][] = $row->id;
}
return $sessions;
}
?>