-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgestadm.php
executable file
·291 lines (277 loc) · 14 KB
/
gestadm.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
<?php
require_once("auth.php");
require_once("../fonctions/divers.php");
if (!est_autorise("acces_configuration"))
exit;
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$errorCode = 0;
$errorMessage = "";
$errorMultiple = false;
$errorMultipleArray = array();
if (false == $langue = $request->get("lang", false))
$langue = ActionsLang::instance()->get_id_langue_courante();
try
{
ActionsAdminAdministrateur::getInstance()->action($request);
} catch(TheliaAdminException $e) {
Tlog::error($e->getMessage());
$errorCode = $e->getCode();
$errorMessage = $e->getMessage();
if($e->getCode() == TheliaAdminException::ADMIN_MULTIPLE_ERRORS)
{
$errorMultiple = true;
$errorMultipleArray = $e->getData();
}
}
$administrateur = new Administrateur();
$langs = LangAdmin::getInstance()->getList();
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php require_once("title.php"); ?>
</head>
<body>
<?php
ActionsAdminModules::instance()->inclure_module_admin("gestadmin_top");
$menu = "configuration";
$breadcrumbs = Breadcrumb::getInstance()->getConfigurationList(trad('Gestion_administrateurs', 'admin'));
require_once("entete.php");
?>
<form method="post" action="gestadm.php">
<input type="hidden" name="action" value="modifier">
<div class="row-fluid">
<div class="span12">
<h3>
<?php echo trad('LISTE_ADMINISTRATEURS', 'admin'); ?>
<div class="btn-group">
<a class="btn btn-large" title="<?php echo trad('ajouter', 'admin'); ?>" href="#adminAddModal" data-toggle="modal">
<i class="icon-plus-sign icon-white"></i>
</a>
</div>
</h3>
<?php
ActionsAdminModules::instance()->inclure_module_admin("gestadm");
?>
<div class="bigtable">
<table class="table table-striped">
<thead>
<tr>
<th><?php echo trad('Nom', 'admin'); ?></th>
<th><?php echo trad('Prenom', 'admin'); ?></th>
<th><?php echo trad('Identifiant', 'admin'); ?></th>
<th><?php echo trad('Langue', 'admin'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach(AdministrateurAdmin::getInstance()->getList() as $admin): ?>
<tr <?php if($errorMultiple && array_key_exists($admin->id, $errorMultipleArray)): ?> class="error" <?php endif; ?>>
<td><input type="text" name="nom[<?php echo $admin->id; ?>]" value="<?php echo $admin->nom; ?>"></td>
<td><input type="text" name="prenom[<?php echo $admin->id; ?>]" value="<?php echo $admin->prenom; ?>"></td>
<td><input type="text" name="identifiant[<?php echo $admin->id; ?>]" value="<?php echo $admin->identifiant; ?>"></td>
<td>
<select name="lang[<?php echo $admin->id; ?>]">
<?php foreach($langs as $lang): ?>
<option value="<?php echo $lang->id; ?>" <?php if($admin->lang == $lang->id) echo 'selected="selected"' ?>><?php echo $lang->description; ?></option>
<?php endforeach; ?>
</select>
</td>
<td>
<div class="btn-group">
<button type="button" title="<?php echo trad("Change_password", "admin"); ?>" class="btn btn-mini js-edit-admin" admin-id="<?php echo $admin->id; ?>">
<i class="icon-lock"></i>
</button>
<?php
if($admin->id != $_SESSION['util']->id) {
?>
<a type="button" title="<?php echo trad("Edit_permissions", "admin"); ?>" href="gestadm_droits.php?administrateur=<?php echo $admin->id; ?>" class="btn btn-mini">
<i class="icon-edit"></i>
</a>
<?php
}
?>
<?php
if($admin->id != $_SESSION['util']->id) {
?>
<a class="btn btn-mini js-delete-admin" title="<?php echo trad("supprimer", "admin"); ?>" href="#deleteModal" data-toggle="modal" admin-info="<?php echo $admin->nom ?> <?php echo $admin->prenom ?>" admin-id="<?php echo $admin->id ?>">
<i class="icon-trash"></i>
</a>
<?php
}
?>
</div>
</td>
</tr>
<?php if($errorMultiple && array_key_exists($admin->id, $errorMultipleArray)): ?>
<tr class="error">
<td colspan="4">
<ul>
<?php $errors = $errorMultipleArray[$admin->id]; ?>
<?php foreach($errors as $error): ?>
<li><?php echo trad("admin_error_".$error, "admin"); ?></li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<?php
ActionsAdminModules::instance()->inclure_module_admin("gestadm");
?>
</div>
</div>
<p>
<button class="btn btn-large btn-block btn-primary" type="submit"><?php echo trad('VALIDER_LES_MODIFICATIONS', 'admin'); ?></button>
</p>
</form>
<div class="modal hide fade in" id="adminAddModal">
<form method="post" action="gestadm.php">
<input type="hidden" name="action" value="ajouter">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><?php echo trad('AJOUTER_ADMINISTRATEUR', 'admin'); ?></h3>
</div>
<div class="modal-body">
<?php if($request->get("action") == "ajouter" && $errorCode > 0): ?>
<div class="alert alert-block alert-error fade in" id="warningAddAdmin">
<h4 class="alert-heading"><?php echo trad('Cautious', 'admin'); ?></h4>
<p><?php echo trad('admin_error_'.$errorCode, 'admin'); ?></p>
</div>
<?php endif; ?>
<table class="table table-striped">
<tbody>
<tr>
<td><?php echo trad('Nom', 'admin'); ?></td>
<td><input type="text" name="nom" value="<?php if($request->get("action") == "ajouter" && $errorCode > 0) echo $request->request->get("nom"); ?>" ></td>
</tr>
<tr>
<td><?php echo trad('Prenom', 'admin'); ?></td>
<td><input type="text" name="prenom" value="<?php if($request->get("action") == "ajouter" && $errorCode > 0) echo $request->request->get("prenom"); ?>" ></td>
</tr>
<tr>
<td><?php echo trad('Identifiant', 'admin'); ?></td>
<td><input type="text" name="identifiant" value="<?php if($request->get("action") == "ajouter" && $errorCode > 0) echo $request->request->get("identifiant"); ?>" ></td>
</tr>
<tr>
<td><?php echo trad('Mdp', 'admin'); ?></td>
<td><input type="password" name="password" ></td>
</tr>
<tr>
<td><?php echo trad('Confirmation', 'admin'); ?></td>
<td><input type="password" name="verifyPassword" ></td>
</tr>
<tr>
<td><?php echo trad('Langue', 'admin'); ?></td>
<td>
<select name="lang">
<?php foreach($langs as $lang): ?>
<option value="<?php echo $lang->id; ?>" <?php if($lang->defaut): ?> selected="selected" <?php endif; ?>><?php echo $lang->description; ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td><?php echo trad('Profil', 'admin'); ?></td>
<td>
<select name="profil">
<?php foreach($administrateur->query_liste("SELECT profil, titre FROM ".Profildesc::TABLE." WHERE lang=".$langue) as $profildesc): ?>
<option value="<?php echo $profildesc->profil; ?>" <?php if($request->get("action") == "ajouter" && $errorCode > 0 && $request->request->get("profil") == $profildesc->profil ) echo 'selected="selected"'; ?>><?php echo $profildesc->titre; ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<a class="btn" data-dismiss="modal" aria-hidden="true"><?php echo trad('Cancel', 'admin'); ?></a>
<button type="submit" class="btn btn-primary"><?php echo trad('Ajouter', 'admin'); ?></button>
</div>
</form>
</div>
<div class="modal hide fade in" id="editAdmin">
<form method="post" action="gestadm.php">
<input type="hidden" name="action" value="modifier_password">
<input type="hidden" name="id" id="admin_id" value="<?php if($request->get("action") == "modifier_password" && $errorCode > 0) echo $request->request->get("id"); ?>">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><?php echo trad('MODIF_PASSWORD', 'admin'); ?></h3>
</div>
<div class="modal-body">
<?php if($request->get("action") == "modifier_password" && $errorCode > 0): ?>
<div class="alert alert-block alert-error fade in" id="warningEditAdmin">
<h4 class="alert-heading"><?php echo trad('Cautious', 'admin'); ?></h4>
<p><?php echo trad('admin_error_'.$errorCode, 'admin'); ?></p>
</div>
<?php endif; ?>
<table class="table table-striped">
<tbody>
<tr>
<td><?php echo trad('Mdp', 'admin'); ?></td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td><?php echo trad('Confirmation', 'admin'); ?></td>
<td><input type="password" name="verifyPassword"></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<a class="btn" data-dismiss="modal" aria-hidden="true"><?php echo trad('Cancel', 'admin'); ?></a>
<button type="submit" class="btn btn-primary"><?php echo trad('Modifier', 'admin'); ?></button>
</div>
</form>
</div>
<!-- admin delation -->
<div class="modal hide" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><?php echo trad('Cautious', 'admin'); ?></h3>
</div>
<div class="modal-body">
<p><?php echo trad('DeleteAdminWarning', 'admin'); ?></p>
<p id="adminDelationInfo"></p>
</div>
<div class="modal-footer">
<a class="btn" data-dismiss="modal" aria-hidden="true"><?php echo trad('Non', 'admin'); ?></a>
<a class="btn btn-primary" id="adminDelationLink"><?php echo trad('Oui', 'admin'); ?></a>
</div>
</div>
<?php
ActionsAdminModules::instance()->inclure_module_admin("gestadm_bottom");
?>
<?php require_once("pied.php"); ?>
</body>
<script type="text/javascript">
$(".js-edit-admin").click(function(){
$("#admin_id").attr("value",$(this).attr("admin-id"));
$("#editAdmin").modal("show");
});
$('.js-delete-admin').click(function()
{
$('#adminDelationInfo').html($(this).attr('admin-info'));
$('#adminDelationLink').attr('href', 'gestadm.php?action=delete&administrateur=' + $(this).attr('admin-id'));
});
<?php if($request->get("action") == "ajouter" && $errorCode > 0): ?>
$("#adminAddModal").modal("show");
$("#adminAddModal").on("hidden",function(){
$("#warningAddAdmin").remove();
});
<?php endif; ?>
<?php if($request->get("action") == "modifier_password" && $errorCode > 0): ?>
$("#editAdmin").modal("show");
$("#editAdmin").on("hidden",function(){
$("#warningEditAdmin").remove();
});
<?php endif; ?>
</script>
</html>