Commit | Line | Data |
---|---|---|
86f0a6af | 1 | <?php |
2 | /*************************************************************************** | |
fc34b3d1 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
86f0a6af | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | class AdminModule extends PLModule | |
23 | { | |
24 | function handlers() | |
25 | { | |
26 | return array( | |
eb5a266d | 27 | 'phpinfo' => $this->make_hook('phpinfo', AUTH_MDP, 'admin'), |
93e38398 | 28 | 'get_rights' => $this->make_hook('get_rights', AUTH_COOKIE, 'admin'), |
b47cc6f0 | 29 | 'set_skin' => $this->make_hook('set_skin', AUTH_COOKIE, 'admin'), |
eb5a266d | 30 | 'admin' => $this->make_hook('default', AUTH_MDP, 'admin'), |
eb5a266d SJ |
31 | 'admin/dead-but-active' => $this->make_hook('dead_but_active', AUTH_MDP, 'admin'), |
32 | 'admin/deaths' => $this->make_hook('deaths', AUTH_MDP, 'admin'), | |
33 | 'admin/downtime' => $this->make_hook('downtime', AUTH_MDP, 'admin'), | |
34 | 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP, 'admin'), | |
35 | 'admin/logger' => $this->make_hook('logger', AUTH_MDP, 'admin'), | |
36 | 'admin/logger/actions' => $this->make_hook('logger_actions', AUTH_MDP, 'admin'), | |
37 | 'admin/postfix/blacklist' => $this->make_hook('postfix_blacklist', AUTH_MDP, 'admin'), | |
38 | 'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP, 'admin'), | |
e7ae7df9 | 39 | 'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP, 'admin'), |
eb5a266d SJ |
40 | 'admin/postfix/whitelist' => $this->make_hook('postfix_whitelist', AUTH_MDP, 'admin'), |
41 | 'admin/mx/broken' => $this->make_hook('mx_broken', AUTH_MDP, 'admin'), | |
42 | 'admin/skins' => $this->make_hook('skins', AUTH_MDP, 'admin'), | |
eb5a266d | 43 | 'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'), |
e02d9fbb | 44 | 'admin/add_accounts' => $this->make_hook('add_accounts', AUTH_MDP, 'admin'), |
e33b29e5 | 45 | 'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin,edit_directory'), |
eb5a266d SJ |
46 | 'admin/validate/answers' => $this->make_hook('validate_answers', AUTH_MDP, 'admin'), |
47 | 'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'), | |
48 | 'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'), | |
49 | 'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'), | |
a7fada4f | 50 | 'admin/geocoding' => $this->make_hook('geocoding', AUTH_MDP, 'admin'), |
eb5a266d | 51 | 'admin/accounts' => $this->make_hook('accounts', AUTH_MDP, 'admin'), |
8338711c | 52 | 'admin/account/watch' => $this->make_hook('account_watch', AUTH_MDP, 'admin'), |
d1e61677 | 53 | 'admin/account/types' => $this->make_hook('account_types', AUTH_MDP, 'admin'), |
ef7de370 | 54 | 'admin/jobs' => $this->make_hook('jobs', AUTH_MDP, 'admin,edit_directory'), |
4d5946ac | 55 | 'admin/profile' => $this->make_hook('profile', AUTH_MDP, 'admin,edit_directory') |
86f0a6af | 56 | ); |
57 | } | |
58 | ||
5f9a40b4 | 59 | function handler_phpinfo(&$page) |
60 | { | |
61 | phpinfo(); | |
62 | exit; | |
63 | } | |
64 | ||
20b087ff | 65 | function handler_get_rights(&$page) |
866bd535 FB |
66 | { |
67 | if (S::suid()) { | |
68 | $page->kill('Déjà en SUID'); | |
69 | } | |
20b087ff FB |
70 | S::assert_xsrf_token(); |
71 | $level = Post::s('account_type'); | |
72 | if ($level != 'admin') { | |
73 | $user = User::getSilentWithUID(S::user()->id()); | |
74 | $user->is_admin = false; | |
75 | $types = DirEnum::getOptions(DirEnum::ACCOUNTTYPES); | |
76 | if (!empty($types[$level])) { | |
77 | $user->setPerms($types[$level]); | |
78 | } | |
79 | S::set('suid_startpage', $_SERVER['HTTP_REFERER']); | |
80 | Platal::session()->startSUID($user); | |
81 | } | |
82 | if (!empty($_SERVER['HTTP_REFERER'])) { | |
83 | http_redirect($_SERVER['HTTP_REFERER']); | |
84 | } else { | |
85 | pl_redirect('/'); | |
86 | } | |
866bd535 FB |
87 | } |
88 | ||
b47cc6f0 FB |
89 | function handler_set_skin(&$page) |
90 | { | |
91 | S::assert_xsrf_token(); | |
92 | S::set('skin', Post::s('change_skin')); | |
93 | if (!empty($_SERVER['HTTP_REFERER'])) { | |
94 | http_redirect($_SERVER['HTTP_REFERER']); | |
95 | } else { | |
96 | pl_redirect('/'); | |
97 | } | |
98 | } | |
99 | ||
86f0a6af | 100 | function handler_default(&$page) |
101 | { | |
102 | $page->changeTpl('admin/index.tpl'); | |
46f272fe | 103 | $page->setTitle('Administration'); |
86f0a6af | 104 | } |
105 | ||
106 | function handler_postfix_delayed(&$page) | |
107 | { | |
108 | $page->changeTpl('admin/postfix_delayed.tpl'); | |
46f272fe | 109 | $page->setTitle('Administration - Postfix : Retardés'); |
86f0a6af | 110 | |
111 | if (Env::has('del')) { | |
112 | $crc = Env::v('crc'); | |
113 | XDB::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc); | |
6bb2f79a | 114 | $page->trigSuccess($crc . " verra tous ses emails supprimés !"); |
86f0a6af | 115 | } elseif (Env::has('ok')) { |
116 | $crc = Env::v('crc'); | |
117 | XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); | |
6bb2f79a | 118 | $page->trigSuccess($crc . " a le droit de passer !"); |
86f0a6af | 119 | } |
120 | ||
121 | $sql = XDB::iterator( | |
122 | "SELECT crc, nb, update_time, create_time, | |
77fcaa3f SJ |
123 | FIND_IN_SET('del', p.release) AS del, |
124 | FIND_IN_SET('ok', p.release) AS ok | |
125 | FROM postfix_mailseen AS p | |
86f0a6af | 126 | WHERE nb >= 30 |
77fcaa3f | 127 | ORDER BY p.release != ''"); |
86f0a6af | 128 | |
129 | $page->assign_by_ref('mails', $sql); | |
130 | } | |
86f0a6af | 131 | |
441e9e98 | 132 | // {{{ logger view |
86f0a6af | 133 | |
441e9e98 | 134 | /** Retrieves the available days for a given year and month. |
135 | * Obtain a list of days of the given month in the given year | |
136 | * that are within the range of dates that we have log entries for. | |
137 | * | |
138 | * @param integer year | |
139 | * @param integer month | |
140 | * @return array days in that month we have log entries covering. | |
141 | * @private | |
142 | */ | |
143 | function _getDays($year, $month) | |
144 | { | |
145 | // give a 'no filter' option | |
9bef113f PC |
146 | $days = array(); |
147 | $days[0] = "----"; | |
441e9e98 | 148 | |
149 | if ($year && $month) { | |
150 | $day_max = Array(-1, 31, checkdate(2, 29, $year) ? 29 : 28 , 31, | |
151 | 30, 31, 30, 31, 31, 30, 31, 30, 31); | |
152 | $res = XDB::query("SELECT YEAR (MAX(start)), YEAR (MIN(start)), | |
153 | MONTH(MAX(start)), MONTH(MIN(start)), | |
154 | DAYOFMONTH(MAX(start)), | |
155 | DAYOFMONTH(MIN(start)) | |
6586a74f | 156 | FROM log_sessions"); |
441e9e98 | 157 | list($ymax, $ymin, $mmax, $mmin, $dmax, $dmin) = $res->fetchOneRow(); |
158 | ||
159 | if (($year < $ymin) || ($year == $ymin && $month < $mmin)) { | |
160 | return array(); | |
161 | } | |
162 | ||
163 | if (($year > $ymax) || ($year == $ymax && $month > $mmax)) { | |
164 | return array(); | |
165 | } | |
166 | ||
167 | $min = ($year==$ymin && $month==$mmin) ? intval($dmin) : 1; | |
168 | $max = ($year==$ymax && $month==$mmax) ? intval($dmax) : $day_max[$month]; | |
169 | ||
170 | for($i = $min; $i<=$max; $i++) { | |
171 | $days[$i] = $i; | |
172 | } | |
173 | } | |
174 | return $days; | |
175 | } | |
176 | ||
177 | ||
178 | /** Retrieves the available months for a given year. | |
179 | * Obtains a list of month numbers that are within the timeframe that | |
180 | * we have log entries for. | |
181 | * | |
182 | * @param integer year | |
183 | * @return array List of month numbers we have log info for. | |
184 | * @private | |
185 | */ | |
186 | function _getMonths($year) | |
187 | { | |
188 | // give a 'no filter' option | |
9bef113f | 189 | $months = array(); |
441e9e98 | 190 | $months[0] = "----"; |
191 | ||
192 | if ($year) { | |
193 | $res = XDB::query("SELECT YEAR (MAX(start)), YEAR (MIN(start)), | |
194 | MONTH(MAX(start)), MONTH(MIN(start)) | |
6586a74f | 195 | FROM log_sessions"); |
441e9e98 | 196 | list($ymax, $ymin, $mmax, $mmin) = $res->fetchOneRow(); |
197 | ||
198 | if (($year < $ymin) || ($year > $ymax)) { | |
199 | return array(); | |
200 | } | |
201 | ||
202 | $min = $year == $ymin ? intval($mmin) : 1; | |
203 | $max = $year == $ymax ? intval($mmax) : 12; | |
204 | ||
205 | for($i = $min; $i<=$max; $i++) { | |
206 | $months[$i] = $i; | |
207 | } | |
208 | } | |
209 | return $months; | |
210 | } | |
211 | ||
212 | ||
213 | /** Retrieves the available years. | |
214 | * Obtains a list of years that we have log entries covering. | |
215 | * | |
216 | * @return array years we have log entries for. | |
217 | * @private | |
218 | */ | |
219 | function _getYears() | |
220 | { | |
221 | // give a 'no filter' option | |
9bef113f | 222 | $years = array(); |
441e9e98 | 223 | $years[0] = "----"; |
224 | ||
225 | // retrieve available years | |
6586a74f | 226 | $res = XDB::query("select YEAR(MAX(start)), YEAR(MIN(start)) FROM log_sessions"); |
441e9e98 | 227 | list($max, $min) = $res->fetchOneRow(); |
228 | ||
229 | for($i = intval($min); $i<=$max; $i++) { | |
230 | $years[$i] = $i; | |
231 | } | |
232 | return $years; | |
233 | } | |
234 | ||
235 | ||
236 | /** Make a where clause to get a user's sessions. | |
237 | * Prepare the where clause request that will retrieve the sessions. | |
238 | * | |
239 | * @param $year INTEGER Only get log entries made during the given year. | |
240 | * @param $month INTEGER Only get log entries made during the given month. | |
241 | * @param $day INTEGER Only get log entries made during the given day. | |
242 | * @param $uid INTEGER Only get log entries referring to the given user ID. | |
243 | * | |
244 | * @return STRING the WHERE clause of a query, including the 'WHERE' keyword | |
245 | * @private | |
246 | */ | |
247 | function _makeWhere($year, $month, $day, $uid) | |
248 | { | |
249 | // start constructing the "where" clause | |
250 | $where = array(); | |
251 | ||
252 | if ($uid) | |
9bef113f | 253 | array_push($where, "s.uid='$uid'"); |
441e9e98 | 254 | |
255 | // we were given at least a year | |
256 | if ($year) { | |
257 | if ($day) { | |
258 | $dmin = mktime(0, 0, 0, $month, $day, $year); | |
259 | $dmax = mktime(0, 0, 0, $month, $day+1, $year); | |
260 | } elseif ($month) { | |
261 | $dmin = mktime(0, 0, 0, $month, 1, $year); | |
262 | $dmax = mktime(0, 0, 0, $month+1, 1, $year); | |
263 | } else { | |
264 | $dmin = mktime(0, 0, 0, 1, 1, $year); | |
265 | $dmax = mktime(0, 0, 0, 1, 1, $year+1); | |
266 | } | |
267 | $where[] = "start >= " . date("Ymd000000", $dmin); | |
268 | $where[] = "start < " . date("Ymd000000", $dmax); | |
269 | } | |
270 | ||
271 | if (!empty($where)) { | |
272 | return ' WHERE ' . implode($where, " AND "); | |
273 | } else { | |
274 | return ''; | |
275 | } | |
276 | // WE know it's totally reversed, so better use array_reverse than a SORT BY start DESC | |
277 | } | |
278 | ||
279 | // }}} | |
280 | ||
281 | function handler_logger(&$page, $action = null, $arg = null) { | |
282 | if ($action == 'session') { | |
283 | ||
284 | // we are viewing a session | |
bdbda592 | 285 | $res = XDB::query("SELECT ls.*, a.hruid AS username, sa.hruid AS suer |
6586a74f | 286 | FROM log_sessions AS ls |
bdbda592 FB |
287 | INNER JOIN accounts AS a ON (a.uid = ls.uid) |
288 | LEFT JOIN accounts AS sa ON (sa.uid = ls.suid) | |
441e9e98 | 289 | WHERE ls.id = {?}", $arg); |
290 | ||
291 | $page->assign('session', $a = $res->fetchOneAssoc()); | |
292 | ||
504ccd57 | 293 | $res = XDB::iterator('SELECT a.text, e.data, e.stamp |
6586a74f FB |
294 | FROM log_events AS e |
295 | LEFT JOIN log_actions AS a ON e.action=a.id | |
441e9e98 | 296 | WHERE e.session={?}', $arg); |
297 | while ($myarr = $res->next()) { | |
298 | $page->append('events', $myarr); | |
299 | } | |
300 | ||
c8ab90e7 | 301 | } else { |
441e9e98 | 302 | $loguser = $action == 'user' ? $arg : Env::v('loguser'); |
c8ab90e7 RB |
303 | |
304 | if ($loguser) { | |
305 | $user = User::get($loguser); | |
306 | $loguid = $user->id(); | |
307 | } else { | |
308 | $loguid = null; | |
309 | } | |
441e9e98 | 310 | |
311 | if ($loguid) { | |
312 | $year = Env::i('year'); | |
313 | $month = Env::i('month'); | |
314 | $day = Env::i('day'); | |
315 | } else { | |
316 | $year = Env::i('year', intval(date('Y'))); | |
317 | $month = Env::i('month', intval(date('m'))); | |
318 | $day = Env::i('day', intval(date('d'))); | |
319 | } | |
320 | ||
321 | if (!$year) | |
322 | $month = 0; | |
323 | if (!$month) | |
324 | $day = 0; | |
325 | ||
326 | // smarty assignments | |
327 | // retrieve available years | |
328 | $page->assign('years', $this->_getYears()); | |
329 | $page->assign('year', $year); | |
330 | ||
331 | // retrieve available months for the current year | |
332 | $page->assign('months', $this->_getMonths($year)); | |
333 | $page->assign('month', $month); | |
334 | ||
335 | // retrieve available days for the current year and month | |
336 | $page->assign('days', $this->_getDays($year, $month)); | |
337 | $page->assign('day', $day); | |
338 | ||
339 | $page->assign('loguser', $loguser); | |
340 | // smarty assignments | |
341 | ||
342 | if ($loguid || $year) { | |
343 | ||
344 | // get the requested sessions | |
345 | $where = $this->_makeWhere($year, $month, $day, $loguid); | |
504ccd57 | 346 | $select = "SELECT s.id, s.start, s.uid, |
bdbda592 | 347 | a.hruid as username |
6586a74f | 348 | FROM log_sessions AS s |
bdbda592 | 349 | INNER JOIN accounts AS a ON (a.uid = s.uid) |
441e9e98 | 350 | $where |
351 | ORDER BY start DESC"; | |
352 | $res = XDB::iterator($select); | |
353 | ||
354 | $sessions = array(); | |
355 | while ($mysess = $res->next()) { | |
356 | $mysess['events'] = array(); | |
357 | $sessions[$mysess['id']] = $mysess; | |
358 | } | |
359 | array_reverse($sessions); | |
360 | ||
361 | // attach events | |
362 | $sql = "SELECT s.id, a.text | |
6586a74f FB |
363 | FROM log_sessions AS s |
364 | LEFT JOIN log_events AS e ON(e.session=s.id) | |
365 | INNER JOIN log_actions AS a ON(a.id=e.action) | |
441e9e98 | 366 | $where"; |
367 | ||
368 | $res = XDB::iterator($sql); | |
369 | while ($event = $res->next()) { | |
370 | array_push($sessions[$event['id']]['events'], $event['text']); | |
371 | } | |
372 | $page->assign_by_ref('sessions', $sessions); | |
373 | } else { | |
c8ab90e7 | 374 | $page->assign('msg_nofilters', "Sélectionner une année et/ou un utilisateur"); |
441e9e98 | 375 | } |
86f0a6af | 376 | } |
377 | ||
8b1f8e12 | 378 | $page->changeTpl('admin/logger-view.tpl'); |
86f0a6af | 379 | |
46f272fe | 380 | $page->setTitle('Administration - Logs des sessions'); |
86f0a6af | 381 | } |
382 | ||
f97f90f0 | 383 | function handler_user(&$page, $login = false) |
384 | { | |
84270653 | 385 | global $globals; |
1412adb2 | 386 | $page->changeTpl('admin/user.tpl'); |
f9743cf1 | 387 | $page->setTitle('Administration - Compte'); |
86f0a6af | 388 | |
0c02607e | 389 | if (S::suid()) { |
6bb2f79a | 390 | $page->kill("Déjà en SUID !!!"); |
86f0a6af | 391 | } |
392 | ||
d5fbeef6 | 393 | // Loads the user identity using the environment. |
1ac65dd4 PC |
394 | if ($login) { |
395 | $user = User::get($login); | |
396 | } | |
397 | if (empty($user)) { | |
8338711c | 398 | pl_redirect('admin/accounts'); |
2ff7e020 VZ |
399 | } |
400 | ||
a8a11a70 | 401 | $listClient = new MMList(S::user()); |
4f903ea6 FB |
402 | $login = $user->login(); |
403 | $registered = ($user->state != 'pending'); | |
86f0a6af | 404 | |
4f903ea6 FB |
405 | // Form processing |
406 | if (!empty($_POST)) { | |
407 | S::assert_xsrf_token(); | |
408 | if (Post::has('uid') && Post::i('uid') != $user->id()) { | |
409 | $page->kill('Une erreur s\'est produite'); | |
410 | } | |
86f0a6af | 411 | } |
412 | ||
d5fbeef6 | 413 | // Handles specific requests (AX sync, su, ...). |
9bef113f | 414 | if(Post::has('log_account')) { |
d5fbeef6 | 415 | pl_redirect("admin/logger?loguser=$login&year=".date('Y')."&month=".date('m')); |
86f0a6af | 416 | } |
417 | ||
a19178e9 | 418 | if(Post::has('su_account') && $registered) { |
866bd535 | 419 | if (!Platal::session()->startSUID($user)) { |
83752d10 | 420 | $page->trigError('Impossible d\'effectuer un SUID sur ' . $user->login()); |
f97f90f0 | 421 | } else { |
d5fbeef6 | 422 | pl_redirect(""); |
eaf30d86 | 423 | } |
d5fbeef6 | 424 | } |
86f0a6af | 425 | |
40965e32 SJ |
426 | // Handles account deletion. |
427 | if (Post::has('account_deletion_confirmation')) { | |
428 | $uid = $user->id(); | |
429 | $name = $user->fullName(); | |
4cd83ff8 | 430 | $profile = $user->profile(); |
879d38da | 431 | if ($profile && Post::b('clear_profile')) { |
4cd83ff8 FB |
432 | $user->profile()->clear(); |
433 | } | |
40965e32 | 434 | $user->clear(true); |
879d38da FB |
435 | $page->trigSuccess("L'utilisateur $name ($uid) a bien été désinscrit."); |
436 | if (Post::b('erase_account')) { | |
437 | XDB::execute('DELETE FROM accounts | |
438 | WHERE uid = {?}', | |
439 | $uid); | |
440 | $page->trigSuccess("L'utilisateur $name ($uid) a été supprimé de la base de données"); | |
441 | } | |
40965e32 SJ |
442 | } |
443 | ||
f9743cf1 | 444 | // Account Form {{{ |
83752d10 | 445 | $to_update = array(); |
4f903ea6 | 446 | if (Post::has('disable_weak_access')) { |
83752d10 | 447 | $to_update['weak_password'] = null; |
4f903ea6 | 448 | } else if (Post::has('update_account')) { |
aef87266 SJ |
449 | if (!$user->hasProfile()) { |
450 | if (Post::s('full_name') != $user->fullName()) { | |
451 | $to_update['full_name'] = Post::s('full_name'); | |
452 | } | |
453 | if (Post::s('display_name') != $user->displayName()) { | |
454 | $to_update['display_name'] = Post::s('display_name'); | |
455 | } | |
456 | if (Post::s('directory_name') != $user->directoryName()) { | |
457 | $to_update['directory_name'] = Post::s('directory_name'); | |
458 | } | |
d081acb2 | 459 | } |
4f903ea6 FB |
460 | if (Post::s('sex') != ($user->isFemale() ? 'female' : 'male')) { |
461 | $to_update['sex'] = Post::s('sex'); | |
aef87266 SJ |
462 | if ($user->hasProfile()) { |
463 | XDB::execute('UPDATE profiles | |
464 | SET sex = {?} | |
465 | WHERE pid = {?}', | |
466 | Post::s('sex'), $user->profile()->id()); | |
467 | } | |
83752d10 | 468 | } |
2477a631 SJ |
469 | if (!Post::blank('pwhash')) { |
470 | $to_update['password'] = Post::s('pwhash'); | |
3168041b | 471 | require_once 'googleapps.inc.php'; |
1549059d VZ |
472 | $account = new GoogleAppsAccount($user); |
473 | if ($account->active() && $account->sync_password) { | |
2477a631 | 474 | $account->set_password(Post::s('pwhash')); |
1549059d | 475 | } |
83752d10 | 476 | } |
4f903ea6 FB |
477 | if (!Post::blank('weak_password')) { |
478 | $to_update['weak_password'] = Post::s('weak_password'); | |
83752d10 | 479 | } |
4f903ea6 FB |
480 | if (Post::i('token_access', 0) != ($user->token_access ? 1 : 0)) { |
481 | $to_update['token'] = Post::i('token_access') ? rand_url_id(16) : null; | |
83752d10 | 482 | } |
fcdbb3bf SJ |
483 | if (Post::i('skin') != $user->skin) { |
484 | $to_update['skin'] = Post::i('skin'); | |
83752d10 | 485 | if ($to_update['skin'] == 0) { |
7cfaf494 | 486 | $to_update['skin'] = null; |
83752d10 FB |
487 | } |
488 | } | |
4f903ea6 FB |
489 | if (Post::s('state') != $user->state) { |
490 | $to_update['state'] = Post::s('state'); | |
83752d10 | 491 | } |
4f903ea6 FB |
492 | if (Post::i('is_admin', 0) != ($user->is_admin ? 1 : 0)) { |
493 | $to_update['is_admin'] = Post::b('is_admin'); | |
83752d10 | 494 | } |
4f903ea6 FB |
495 | if (Post::s('type') != $user->type) { |
496 | $to_update['type'] = Post::s('type'); | |
83752d10 | 497 | } |
4f903ea6 | 498 | if (Post::i('watch', 0) != ($user->watch ? 1 : 0)) { |
83752d10 | 499 | $to_update['flags'] = new PlFlagset(); |
4f903ea6 | 500 | $to_update['flags']->addFlag('watch', Post::i('watch')); |
83752d10 | 501 | } |
4f903ea6 FB |
502 | if (Post::t('comment') != $user->comment) { |
503 | $to_update['comment'] = Post::blank('comment') ? null : Post::t('comment'); | |
83752d10 | 504 | } |
a8a11a70 FB |
505 | if (!$user->checkPerms(User::PERM_MAIL) && Post::t('email') != $user->forlifeEmail()) { |
506 | $to_update['email'] = Post::t('email'); | |
507 | $listClient->change_user_email($user->forlifeEmail(), Post::t('email')); | |
508 | } | |
83752d10 FB |
509 | } |
510 | if (!empty($to_update)) { | |
01f78cbb SJ |
511 | $res = XDB::query('SELECT * |
512 | FROM accounts | |
513 | WHERE uid = {?}', $user->id()); | |
514 | $oldValues = $res->fetchAllAssoc(); | |
515 | $oldValues = $oldValues[0]; | |
516 | ||
83752d10 | 517 | $set = array(); |
01f78cbb | 518 | $diff = array(); |
83752d10 | 519 | foreach ($to_update as $k => $value) { |
01f78cbb SJ |
520 | $value = XDB::format('{?}', $value); |
521 | $set[] = $k . ' = ' . $value; | |
522 | $diff[$k] = array($oldValues[$k], trim($value, "'")); | |
523 | unset($oldValues[$k]); | |
83752d10 | 524 | } |
a8a11a70 FB |
525 | XDB::rawExecute('UPDATE accounts |
526 | SET ' . implode(', ', $set) . ' | |
527 | WHERE uid = ' . XDB::format('{?}', $user->id())); | |
83752d10 FB |
528 | $page->trigSuccess('Données du compte mise à jour avec succès'); |
529 | $user = User::getWithUID($user->id()); | |
01f78cbb SJ |
530 | |
531 | /* Formats the $diff and send it to the site administrators. The rules are the folowing: | |
532 | * -formats: password, token, weak_password | |
533 | */ | |
534 | foreach (array('password', 'token', 'weak_password') as $key) { | |
535 | if (isset($diff[$key])) { | |
536 | $diff[$key] = array('old value', 'new value'); | |
537 | } else { | |
538 | $oldValues[$key] = 'old value'; | |
539 | } | |
540 | } | |
541 | ||
542 | $mail = new PlMailer('admin/useredit.mail.tpl'); | |
543 | $mail->assign('admin', S::user()->hruid); | |
544 | $mail->assign('hruid', $user->hruid); | |
545 | $mail->assign('diff', $diff); | |
546 | $mail->assign('oldValues', $oldValues); | |
547 | $mail->send(); | |
83752d10 | 548 | } |
f9743cf1 | 549 | // }}} |
4f903ea6 | 550 | |
f9743cf1 | 551 | // Profile form {{{ |
4f903ea6 FB |
552 | if (Post::has('add_profile') || Post::has('del_profile') || Post::has('owner')) { |
553 | if (Post::i('del_profile', 0) != 0) { | |
f9743cf1 FB |
554 | XDB::execute('DELETE FROM account_profiles |
555 | WHERE uid = {?} AND pid = {?}', | |
4f903ea6 FB |
556 | $user->id(), Post::i('del_profile')); |
557 | } else if (!Post::blank('new_profile')) { | |
558 | $profile = Profile::get(Post::t('new_profile')); | |
f9743cf1 | 559 | if (!$profile) { |
4f903ea6 | 560 | $page->trigError('Le profil ' . Post::t('new_profile') . ' n\'existe pas'); |
f9743cf1 FB |
561 | } else { |
562 | XDB::execute('INSERT IGNORE INTO account_profiles (uid, pid) | |
563 | VALUES ({?}, {?})', | |
564 | $user->id(), $profile->id()); | |
565 | } | |
566 | } | |
567 | XDB::execute('UPDATE account_profiles | |
568 | SET perms = IF(pid = {?}, CONCAT(perms, \',owner\'), REPLACE(perms, \'owner\', \'\')) | |
569 | WHERE uid = {?}', | |
4f903ea6 | 570 | Post::i('owner'), $user->id()); |
f9743cf1 | 571 | } |
f9743cf1 FB |
572 | // }}} |
573 | ||
4f903ea6 FB |
574 | // Email forwards form {{{ |
575 | require_once("emails.inc.php"); | |
576 | $redirect = ($registered ? new Redirect($user) : null); | |
577 | if (Post::has('add_fwd')) { | |
578 | $email = Post::t('email'); | |
579 | if (!isvalid_email_redirection($email)) { | |
580 | $page->trigError("Email non valide: $email"); | |
581 | } else { | |
582 | $redirect->add_email($email); | |
583 | $page->trigSuccess("Ajout de $email effectué"); | |
584 | } | |
585 | } else if (!Post::blank('del_fwd')) { | |
586 | $redirect->delete_email(Post::t('del_fwd')); | |
587 | } else if (!Post::blank('activate_fwd')) { | |
588 | $redirect->modify_one_email(Post::t('activate_fwd', true)); | |
589 | } else if (!Post::blank('deactivate_fwd')) { | |
590 | $redirect->modify_one_email(Post::t('deactivate_fwd', false)); | |
591 | } else if (Post::has('disable_fwd')) { | |
592 | $redirect->disable(); | |
593 | } else if (Post::has('enable_fwd')) { | |
594 | $redirect->enable(); | |
595 | } else if (!Post::blank('clean_fwd')) { | |
596 | $redirect->clean_errors(Post::t('clean_fwd')); | |
597 | } | |
598 | // }}} | |
d5fbeef6 | 599 | |
4f903ea6 FB |
600 | // Email alias form {{{ |
601 | if (Post::has('add_alias')) { | |
602 | // Splits new alias in user and fqdn. | |
603 | $alias = Env::t('email'); | |
604 | if (strpos($alias, '@') !== false) { | |
605 | list($alias, $domain) = explode('@', $alias); | |
606 | } else { | |
607 | $domain = $globals->mail->domain; | |
608 | } | |
84270653 | 609 | |
4f903ea6 FB |
610 | // Checks for alias' user validity. |
611 | if (!preg_match('/[-a-z0-9\.]+/s', $alias)) { | |
612 | $page->trigError("'$alias' n'est pas un alias valide"); | |
613 | } | |
86f0a6af | 614 | |
4f903ea6 FB |
615 | // Eventually adds the alias to the right domain. |
616 | if ($domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2) { | |
617 | $req = new AliasReq($user, $alias, 'Admin request', false); | |
618 | if ($req->commit()) { | |
619 | $page->trigSuccess("Nouvel alias '$alias@$domain' attribué"); | |
620 | } else { | |
621 | $page->trigError("Impossible d'ajouter l'alias '$alias@$domain', il est probablement déjà attribué"); | |
622 | } | |
623 | } elseif ($domain == $globals->mail->domain || $domain == $globals->mail->domain2) { | |
fe13bc1d | 624 | $res = XDB::execute("INSERT INTO aliases (uid, alias, type) |
4f903ea6 FB |
625 | VALUES ({?}, {?}, 'alias')", |
626 | $user->id(), $alias); | |
627 | $page->trigSuccess("Nouvel alias '$alias' ajouté"); | |
628 | } else { | |
629 | $page->trigError("Le domaine '$domain' n'est pas valide"); | |
630 | } | |
631 | } else if (!Post::blank('del_alias')) { | |
632 | XDB::execute("DELETE FROM aliases | |
fe13bc1d | 633 | WHERE uid = {?} AND alias = {?} AND |
4f903ea6 FB |
634 | type NOT IN ('a_vie', 'homonyme')", |
635 | $user->id(), $val); | |
636 | XDB::execute("UPDATE emails | |
637 | SET rewrite = '' | |
638 | WHERE uid = {?} AND rewrite LIKE CONCAT({?}, '@%')", | |
639 | $user->id(), $val); | |
640 | fix_bestalias($user); | |
641 | $page->trigSuccess("L'alias '$val' a été supprimé"); | |
642 | } else if (!Post::blank('best')) { | |
643 | XDB::execute("UPDATE aliases | |
644 | SET flags = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', flags, ','), ',bestalias,', ',')) | |
fe13bc1d | 645 | WHERE uid = {?}", $user->id()); |
4f903ea6 FB |
646 | XDB::execute("UPDATE aliases |
647 | SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'bestalias') | |
fe13bc1d | 648 | WHERE uid = {?} AND alias = {?}", $user->id(), $val); |
4f903ea6 FB |
649 | // As having a non-null bestalias value is critical in |
650 | // plat/al's code, we do an a posteriori check on the | |
651 | // validity of the bestalias. | |
652 | fix_bestalias($user); | |
653 | } | |
654 | // }}} | |
669cb0e0 | 655 | |
83353c71 FB |
656 | // OpenId form {{{ |
657 | if (Post::has('del_openid')) { | |
864957c1 | 658 | XDB::execute('DELETE FROM account_auth_openid |
83353c71 FB |
659 | WHERE id = {?}', Post::i('del_openid')); |
660 | } | |
661 | // }}} | |
662 | ||
4f903ea6 FB |
663 | // Forum form {{{ |
664 | if (Post::has('b_edit')) { | |
665 | XDB::execute("DELETE FROM forum_innd | |
666 | WHERE uid = {?}", $user->id()); | |
667 | if (Env::v('write_perm') != "" || Env::v('read_perm') != "" || Env::v('commentaire') != "" ) { | |
668 | XDB::execute("INSERT INTO forum_innd | |
669 | SET ipmin = '0', ipmax = '4294967295', | |
670 | write_perm = {?}, read_perm = {?}, | |
671 | comment = {?}, priority = '200', uid = {?}", | |
672 | Env::v('write_perm'), Env::v('read_perm'), Env::v('comment'), $user->id()); | |
673 | } | |
674 | } | |
675 | // }}} | |
86f0a6af | 676 | |
86f0a6af | 677 | |
889d9807 | 678 | $page->addJsLink('jquery.ui.core.js'); |
1b50c20c | 679 | $page->addJsLink('jquery.ui.widget.js'); |
889d9807 | 680 | $page->addJsLink('jquery.ui.tabs.js'); |
2477a631 | 681 | $page->addJsLink('password.js'); |
669cb0e0 | 682 | |
d5fbeef6 VZ |
683 | // Displays last login and last host information. |
684 | $res = XDB::query("SELECT start, host | |
6586a74f | 685 | FROM log_sessions |
d5fbeef6 VZ |
686 | WHERE uid = {?} AND suid = 0 |
687 | ORDER BY start DESC | |
688 | LIMIT 1", $user->id()); | |
689 | list($lastlogin,$host) = $res->fetchOneRow(); | |
690 | $page->assign('lastlogin', $lastlogin); | |
691 | $page->assign('host', $host); | |
692 | ||
1d889ac4 | 693 | // Display mailing lists |
a8a11a70 | 694 | $page->assign('mlists', $listClient->get_all_user_lists($user->forlifeEmail())); |
1d889ac4 | 695 | |
d5fbeef6 | 696 | // Display active aliases. |
8f2104cb | 697 | $page->assign('virtuals', $user->emailAliases()); |
4f903ea6 FB |
698 | $page->assign('aliases', XDB::iterator("SELECT alias, type='a_vie' AS for_life, |
699 | FIND_IN_SET('bestalias',flags) AS best, expire | |
700 | FROM aliases | |
fe13bc1d | 701 | WHERE uid = {?} AND type != 'homonyme' |
4f903ea6 | 702 | ORDER BY type != 'a_vie'", $user->id())); |
8f2104cb FB |
703 | $page->assign('account_types', XDB::iterator('SELECT * FROM account_types ORDER BY type')); |
704 | $page->assign('skins', XDB::iterator('SELECT id, name FROM skins ORDER BY name')); | |
f9743cf1 FB |
705 | $page->assign('profiles', XDB::iterator('SELECT p.pid, p.hrpid, FIND_IN_SET(\'owner\', ap.perms) AS owner |
706 | FROM account_profiles AS ap | |
707 | INNER JOIN profiles AS p ON (ap.pid = p.pid) | |
708 | WHERE ap.uid = {?}', $user->id())); | |
83353c71 | 709 | $page->assign('openid', XDB::iterator('SELECT id, url |
864957c1 FB |
710 | FROM account_auth_openid |
711 | WHERE uid = {?}', $user->id())); | |
d5fbeef6 VZ |
712 | |
713 | // Displays email redirection and the general profile. | |
714 | if ($registered && $redirect) { | |
715 | $page->assign('emails', $redirect->emails); | |
716 | } | |
717 | ||
d5fbeef6 | 718 | $page->assign('user', $user); |
aef87266 | 719 | $page->assign('hasProfile', $user->hasProfile()); |
d5fbeef6 VZ |
720 | |
721 | // Displays forum bans. | |
722 | $res = XDB::query("SELECT write_perm, read_perm, comment | |
7d15f750 | 723 | FROM forum_innd |
d5fbeef6 VZ |
724 | WHERE uid = {?}", $user->id()); |
725 | $bans = $res->fetchOneAssoc(); | |
726 | $page->assign('bans', $bans); | |
86f0a6af | 727 | } |
1f53925a | 728 | |
e02d9fbb | 729 | private static function getHrid($firstname, $lastname, $promo) |
7c5200a5 | 730 | { |
e02d9fbb | 731 | if ($firstname != null && $lastname != null && $promo != null) { |
69fc05dd | 732 | return User::makeHrid($firstname, $lastname, $promo); |
7c5200a5 | 733 | } |
f6eacab0 | 734 | return null; |
7c5200a5 VZ |
735 | } |
736 | ||
cb0c8b1c | 737 | private static function formatNewUser(&$page, $infosLine, $separator, $promo, $size) |
1f53925a | 738 | { |
e02d9fbb | 739 | $infos = explode($separator, $infosLine); |
cb0c8b1c SJ |
740 | if (sizeof($infos) > $size || sizeof($infos) < 2) { |
741 | $page->trigError("La ligne $infosLine n'a pas été ajoutée."); | |
e02d9fbb | 742 | return false; |
1f53925a | 743 | } |
744 | ||
16714428 | 745 | $infos = array_map('trim', $infos); |
e02d9fbb SJ |
746 | $hrid = self::getHrid($infos[1], $infos[0], $promo); |
747 | $res1 = XDB::query('SELECT COUNT(*) | |
748 | FROM accounts | |
749 | WHERE hruid = {?}', $hrid); | |
750 | $res2 = XDB::query('SELECT COUNT(*) | |
751 | FROM profiles | |
752 | WHERE hrpid = {?}', $hrid); | |
753 | if (is_null($hrid) || $res1->fetchOneCell() > 0 || $res2->fetchOneCell() > 0) { | |
981fce7b | 754 | $page->trigError("La ligne $infosLine n'a pas été ajoutée: une entrée similaire existe déjà"); |
e02d9fbb SJ |
755 | return false; |
756 | } | |
757 | $infos['hrid'] = $hrid; | |
758 | return $infos; | |
759 | } | |
760 | ||
761 | private static function formatSex(&$page, $sex, $line) | |
762 | { | |
763 | switch ($sex) { | |
764 | case 'F': | |
765 | return PlUser::GENDER_FEMALE; | |
766 | case 'M': | |
767 | return PlUser::GENDER_MALE; | |
768 | default: | |
769 | $page->trigError("La ligne $line n'a pas été ajoutée car le sexe $sex n'est pas pris en compte."); | |
770 | return null; | |
1f53925a | 771 | } |
e02d9fbb | 772 | } |
1f53925a | 773 | |
e02d9fbb SJ |
774 | private static function formatBirthDate($birthDate) |
775 | { | |
16714428 RB |
776 | // strtotime believes dd/mm/yyyy to be an US date (i.e mm/dd/yyyy), and |
777 | // dd-mm-yyyy to be a normal date (i.e dd-mm-yyyy)... | |
778 | return date("Y-m-d", strtotime(str_replace('/', '-', $birthDate))); | |
e02d9fbb SJ |
779 | } |
780 | ||
781 | function handler_add_accounts(&$page, $action = null, $promo = null) | |
782 | { | |
783 | $page->changeTpl('admin/add_accounts.tpl'); | |
784 | ||
785 | if (Env::has('add_type') && Env::has('people')) { | |
e02d9fbb SJ |
786 | $lines = explode("\n", Env::t('people')); |
787 | $separator = Env::t('separator'); | |
788 | $promotion = Env::i('promotion'); | |
94590511 | 789 | $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES); |
e02d9fbb SJ |
790 | $nameTypes = array_flip($nameTypes); |
791 | ||
792 | if (Env::t('add_type') == 'promo') { | |
793 | $type = 'x'; | |
94590511 | 794 | $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS); |
e02d9fbb | 795 | $eduSchools = array_flip($eduSchools); |
94590511 | 796 | $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); |
e02d9fbb | 797 | $eduDegrees = array_flip($eduDegrees); |
e02d9fbb SJ |
798 | switch (Env::t('edu_type')) { |
799 | case 'X': | |
800 | $degreeid = $eduDegrees[Profile::DEGREE_X]; | |
801 | $entry_year = $promotion; | |
802 | $grad_year = $promotion + 3; | |
803 | $promo = 'X' . $promotion; | |
d9e99995 | 804 | $hrpromo = $promotion; |
e02d9fbb SJ |
805 | break; |
806 | case 'M': | |
807 | $degreeid = $eduDegrees[Profile::DEGREE_M]; | |
808 | $grad_year = $promotion; | |
809 | $entry_year = $promotion - 2; | |
810 | $promo = 'M' . $promotion; | |
d9e99995 FB |
811 | $hrpromo = $promo; |
812 | $type = 'master'; | |
e02d9fbb SJ |
813 | break; |
814 | case 'D': | |
815 | $degreeid = $eduDegrees[Profile::DEGREE_D]; | |
816 | $grad_year = $promotion; | |
817 | $entry_year = $promotion - 3; | |
818 | $promo = 'D' . $promotion; | |
d9e99995 FB |
819 | $hrpromo = $promo; |
820 | $type = 'phd'; | |
e02d9fbb SJ |
821 | break; |
822 | default: | |
823 | $page->killError("La formation n'est pas reconnue:" . Env::t('edu_type') . '.'); | |
824 | } | |
825 | ||
7f55b0d6 | 826 | XDB::startTransaction(); |
e02d9fbb | 827 | foreach ($lines as $line) { |
d9e99995 | 828 | if ($infos = self::formatNewUser($page, $line, $separator, $hrpromo, 6)) { |
cb0c8b1c SJ |
829 | $sex = self::formatSex($page, $infos[3], $line); |
830 | if (!is_null($sex)) { | |
4452750b SJ |
831 | $fullName = $infos[1] . ' ' . $infos[0]; |
832 | $directoryName = $infos[0] . ' ' . $infos[1]; | |
cb0c8b1c SJ |
833 | $birthDate = self::formatBirthDate($infos[2]); |
834 | $xorgId = Profile::getXorgId($infos[4]); | |
835 | if (is_null($xorgId)) { | |
836 | $page->trigError("La ligne $line n'a pas été ajoutée car le matricule École est mal renseigné."); | |
837 | continue; | |
838 | } | |
839 | ||
840 | XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, birthdate_ref, sex) | |
841 | VALUES ({?}, {?}, {?}, {?}, {?})', | |
842 | $infos['hrid'], $xorgId, $infos[5], $birthDate, $sex); | |
843 | $pid = XDB::insertId(); | |
844 | XDB::execute('INSERT INTO profile_name (pid, name, typeid) | |
d9e99995 FB |
845 | VALUES ({?}, {?}, {?}), |
846 | ({?}, {?}, {?}), | |
847 | ({?}, {?}, {?}), | |
848 | ({?}, {?}, {?})', | |
849 | $pid, $infos[0], $nameTypes['name_ini'], | |
850 | $pid, $infos[0], $nameTypes['lastname'], | |
851 | $pid, $infos[1], $nameTypes['firstname_ini'], | |
852 | $pid, $infos[1], $nameTypes['firstname']); | |
cb0c8b1c SJ |
853 | XDB::execute('INSERT INTO profile_display (pid, yourself, public_name, private_name, |
854 | directory_name, short_name, sort_name, promo) | |
855 | VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', | |
4452750b | 856 | $pid, $infos[1], $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo); |
cb0c8b1c SJ |
857 | XDB::execute('INSERT INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags) |
858 | VALUES ({?}, {?}, {?}, {?}, {?}, {?})', | |
859 | $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary'); | |
4452750b | 860 | XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex) |
d9e99995 FB |
861 | VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', |
862 | $infos['hrid'], $type, 0, 'pending', $fullName, $directoryName, $infos[1], $sex); | |
cb0c8b1c SJ |
863 | $uid = XDB::insertId(); |
864 | XDB::execute('INSERT INTO account_profiles (uid, pid, perms) | |
865 | VALUES ({?}, {?}, {?})', | |
866 | $uid, $pid, 'owner'); | |
bedc4295 | 867 | Profile::rebuildSearchTokens($pid, false); |
cb0c8b1c | 868 | } |
e02d9fbb SJ |
869 | } |
870 | } | |
7f55b0d6 | 871 | XDB::commit(); |
e02d9fbb SJ |
872 | } else if (Env::t('add_type') == 'account') { |
873 | $type = Env::t('type'); | |
4029afb0 | 874 | $newAccounts = array(); |
e02d9fbb | 875 | foreach ($lines as $line) { |
cb0c8b1c SJ |
876 | if ($infos = self::formatNewUser($page, $line, $separator, $type, 4)) { |
877 | $sex = self::formatSex($page, $infos[3], $line); | |
878 | if (!is_null($sex)) { | |
4452750b SJ |
879 | $fullName = $infos[1] . ' ' . $infos[0]; |
880 | $directoryName = $infos[0] . ' ' . $infos[1]; | |
d9e99995 FB |
881 | XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, |
882 | email, full_name, directory_name, | |
883 | display_name, sex) | |
884 | VALUES ({?}, {?}, {?}, {?}, | |
885 | {?}, {?}, {?}, {?}, {?})', | |
886 | $infos['hrid'], $type, 0, 'pending', | |
887 | $infos[2], $fullName, $directoryName, | |
888 | $infos[1], $sex); | |
4029afb0 | 889 | $newAccounts[$infos['hrid']] = $infos[1] . ' ' . $infos[0]; |
cb0c8b1c | 890 | } |
e02d9fbb SJ |
891 | } |
892 | } | |
4029afb0 SJ |
893 | if (!empty($newAccounts)) { |
894 | $page->assign('newAccounts', $newAccounts); | |
895 | } | |
e02d9fbb SJ |
896 | } else if (Env::t('add_type') == 'ax_id') { |
897 | $type = 'x'; | |
898 | foreach ($lines as $line) { | |
cb0c8b1c | 899 | if ($infos = self::formatNewUser($page, $line, $separator, $promotion, 3)) { |
e02d9fbb SJ |
900 | XDB::execute('UPDATE profiles |
901 | SET ax_id = {?} | |
902 | WHERE hrpid = {?}', | |
903 | $infos[2], $infos['hrid']); | |
904 | } | |
905 | } | |
906 | } | |
907 | ||
cb0c8b1c SJ |
908 | $errors = $page->nb_errs(); |
909 | if ($errors == 0) { | |
e02d9fbb SJ |
910 | $page->trigSuccess("L'opération a été effectuée avec succès."); |
911 | } else { | |
cb0c8b1c SJ |
912 | $page->trigSuccess('L\'opération a été effectuée avec succès, sauf pour ' |
913 | . (($errors == 1) ? 'l\'erreur signalée' : "les $errors erreurs signalées") . ' ci-dessus.'); | |
e02d9fbb SJ |
914 | } |
915 | } else if (Env::has('add_type')) { | |
916 | $res = XDB::query('SELECT type | |
917 | FROM account_types'); | |
918 | $page->assign('account_types', $res->fetchColumn()); | |
919 | $page->assign('add_type', Env::s('add_type')); | |
1f53925a | 920 | } |
1f53925a | 921 | } |
922 | ||
7c5200a5 VZ |
923 | function handler_homonyms(&$page, $op = 'list', $target = null) |
924 | { | |
86f0a6af | 925 | $page->changeTpl('admin/homonymes.tpl'); |
46f272fe | 926 | $page->setTitle('Administration - Homonymes'); |
191711d5 | 927 | $this->load("homonyms.inc.php"); |
74c55fd6 | 928 | |
86f0a6af | 929 | if ($target) { |
191711d5 FB |
930 | $user = User::getSilent($target); |
931 | if (!$user || !($loginbis = select_if_homonyme($user))) { | |
932 | $target = 0; | |
86f0a6af | 933 | } else { |
191711d5 | 934 | $page->assign('user', $user); |
86f0a6af | 935 | $page->assign('loginbis',$loginbis); |
936 | } | |
937 | } | |
74c55fd6 | 938 | |
839a80cf VZ |
939 | $page->assign('op', $op); |
940 | $page->assign('target', $target); | |
74c55fd6 | 941 | |
86f0a6af | 942 | // on a un $target valide, on prepare les mails |
943 | if ($target) { | |
86f0a6af | 944 | // on examine l'op a effectuer |
945 | switch ($op) { | |
946 | case 'mail': | |
40d428d8 VZ |
947 | S::assert_xsrf_token(); |
948 | ||
191711d5 FB |
949 | send_warning_homonyme($user, $loginbis); |
950 | switch_bestalias($user, $loginbis); | |
86f0a6af | 951 | $op = 'list'; |
191711d5 | 952 | $page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . '.'); |
86f0a6af | 953 | break; |
839a80cf | 954 | |
86f0a6af | 955 | case 'correct': |
40d428d8 VZ |
956 | S::assert_xsrf_token(); |
957 | ||
191711d5 | 958 | switch_bestalias($user, $loginbis); |
32b3ac78 FB |
959 | XDB::execute("UPDATE aliases |
960 | SET type = 'homonyme', expire=NOW() | |
961 | WHERE alias = {?}", $loginbis); | |
00ba8a74 SJ |
962 | XDB::execute('INSERT IGNORE INTO homonyms (homonyme_id, uid) |
963 | VALUES ({?}, {?})', $target, $target); | |
191711d5 | 964 | send_robot_homonyme($user, $loginbis); |
86f0a6af | 965 | $op = 'list'; |
191711d5 | 966 | $page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . ', alias supprimé.'); |
86f0a6af | 967 | break; |
968 | } | |
969 | } | |
74c55fd6 | 970 | |
86f0a6af | 971 | if ($op == 'list') { |
972 | $res = XDB::iterator( | |
32b3ac78 | 973 | "SELECT a.alias AS homonyme, s.alias AS forlife, |
e84223d4 PC |
974 | IF(h.homonyme_id = s.uid, a.expire, NULL) AS expire, |
975 | IF(h.homonyme_id = s.uid, a.type, NULL) AS type, ac.uid | |
86f0a6af | 976 | FROM aliases AS a |
1bf36cd1 SJ |
977 | LEFT JOIN homonyms AS h ON (h.homonyme_id = a.uid) |
978 | INNER JOIN aliases AS s ON (s.uid = h.uid AND s.type = 'a_vie') | |
fe13bc1d | 979 | INNER JOIN accounts AS ac ON (ac.uid = a.uid) |
32b3ac78 FB |
980 | WHERE a.type = 'homonyme' OR a.expire != '' |
981 | ORDER BY a.alias, forlife"); | |
86f0a6af | 982 | $hnymes = Array(); |
983 | while ($tab = $res->next()) { | |
984 | $hnymes[$tab['homonyme']][] = $tab; | |
985 | } | |
1bf36cd1 | 986 | $page->assign_by_ref('hnymes', $hnymes); |
86f0a6af | 987 | } |
988 | } | |
74c55fd6 | 989 | |
32b3ac78 FB |
990 | function handler_deaths(&$page, $promo = 0, $validate = false) |
991 | { | |
86f0a6af | 992 | $page->changeTpl('admin/deces_promo.tpl'); |
46f272fe | 993 | $page->setTitle('Administration - Deces'); |
74c55fd6 | 994 | |
dcefa8f7 FB |
995 | if (!$promo) { |
996 | $promo = Env::t('promo', 'X1923'); | |
997 | } | |
998 | $page->assign('promo', $promo); | |
999 | if (!$promo) { | |
1000 | return; | |
1001 | } | |
74c55fd6 | 1002 | |
40d428d8 VZ |
1003 | if ($validate) { |
1004 | S::assert_xsrf_token(); | |
1005 | ||
f198bf30 | 1006 | $res = XDB::iterRow('SELECT p.pid, pd.directory_name, p.deathdate |
dcefa8f7 FB |
1007 | FROM profiles AS p |
1008 | INNER JOIN profile_display AS pd ON (p.pid = pd.pid) | |
1009 | WHERE pd.promo = {?}', $promo); | |
1010 | while (list($pid, $name, $death) = $res->next()) { | |
f198bf30 | 1011 | $val = Env::v('death_' . $pid); |
71497fb8 | 1012 | if ($val == $death) { |
e61326ed VZ |
1013 | continue; |
1014 | } | |
1015 | ||
71497fb8 SJ |
1016 | if (empty($val)) { |
1017 | $val = null; | |
1018 | } | |
dcefa8f7 FB |
1019 | XDB::execute('UPDATE profiles |
1020 | SET deathdate = {?}, deathdate_rec = NOW() | |
f198bf30 | 1021 | WHERE pid = {?}', $val, $pid); |
71497fb8 SJ |
1022 | |
1023 | $page->trigSuccess('Édition du décès de ' . $name . ' (' . ($val ? $val : 'ressuscité') . ').'); | |
1024 | if ($val && ($death == '0000-00-00' || empty($death))) { | |
438b7a0c | 1025 | $profile = Profile::get($pid); |
6150f591 SJ |
1026 | $profile->clear(); |
1027 | $profile->owner()->clear(false); | |
e61326ed | 1028 | } |
86f0a6af | 1029 | } |
86f0a6af | 1030 | } |
74c55fd6 | 1031 | |
f198bf30 | 1032 | $res = XDB::iterator('SELECT p.pid, pd.directory_name, p.deathdate |
dcefa8f7 FB |
1033 | FROM profiles AS p |
1034 | INNER JOIN profile_display AS pd ON (p.pid = pd.pid) | |
1035 | WHERE pd.promo = {?} | |
1036 | ORDER BY pd.sort_name', $promo); | |
71497fb8 | 1037 | $page->assign('profileList', $res); |
86f0a6af | 1038 | } |
74c55fd6 | 1039 | |
32b3ac78 FB |
1040 | function handler_dead_but_active(&$page) |
1041 | { | |
1c48c2a9 | 1042 | $page->changeTpl('admin/dead_but_active.tpl'); |
46f272fe | 1043 | $page->setTitle('Administration - Décédés'); |
1c48c2a9 VZ |
1044 | |
1045 | $res = XDB::iterator( | |
e46cf8c4 | 1046 | "SELECT a.hruid, pd.promo, p.ax_id, pd.directory_name, p.deathdate, DATE(MAX(s.start)) AS last |
fe13bc1d FB |
1047 | FROM accounts AS a |
1048 | INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms)) | |
1049 | INNER JOIN profiles AS p ON (p.pid = ap.pid) | |
1050 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid) | |
6586a74f | 1051 | LEFT JOIN log_sessions AS s ON (s.uid = a.uid AND suid = 0) |
e46cf8c4 | 1052 | WHERE a.state = 'active' AND p.deathdate IS NOT NULL |
dcefa8f7 | 1053 | GROUP BY a.uid |
e46cf8c4 | 1054 | ORDER BY pd.promo, pd.sort_name"); |
1c48c2a9 VZ |
1055 | $page->assign('dead', $res); |
1056 | } | |
1057 | ||
e654517d | 1058 | function handler_validate(&$page, $action = 'list', $id = null) |
1059 | { | |
764b894d | 1060 | $page->changeTpl('admin/validation.tpl'); |
46f272fe | 1061 | $page->setTitle('Administration - Valider une demande'); |
5b8c317d | 1062 | $page->addCssLink('nl.css'); |
e654517d | 1063 | |
5b8c317d | 1064 | if ($action == 'edit' && !is_null($id)) { |
ed5b9703 | 1065 | $page->assign('preview_id', $id); |
5b8c317d SJ |
1066 | } else { |
1067 | $page->assign('preview_id', null); | |
ed5b9703 | 1068 | } |
1069 | ||
86f0a6af | 1070 | if(Env::has('uid') && Env::has('type') && Env::has('stamp')) { |
40d428d8 VZ |
1071 | S::assert_xsrf_token(); |
1072 | ||
20d7932b | 1073 | $req = Validate::get_typed_request(Env::v('uid'), Env::v('type'), Env::v('stamp')); |
343e22c2 FB |
1074 | if ($req) { |
1075 | $req->handle_formu(); | |
1076 | } else { | |
1077 | $page->trigWarning('La validation a déjà été effectuée.'); | |
1078 | } | |
86f0a6af | 1079 | } |
74c55fd6 | 1080 | |
cfb96867 | 1081 | $r = XDB::iterator('SHOW COLUMNS FROM requests_answers'); |
1082 | while (($a = $r->next()) && $a['Field'] != 'category'); | |
1083 | $page->assign('categories', $categories = explode(',', str_replace("'", '', substr($a['Type'], 5, -1)))); | |
74c55fd6 | 1084 | |
cfb96867 | 1085 | $hidden = array(); |
257ae408 SJ |
1086 | $res = XDB::query('SELECT hidden_requests |
1087 | FROM requests_hidden | |
1088 | WHERE uid = {?}', S::v('uid')); | |
e0d7c076 | 1089 | $hide_requests = $res->fetchOneCell(); |
cfb96867 | 1090 | if (Post::has('hide')) { |
74c55fd6 | 1091 | $hide = array(); |
1092 | foreach ($categories as $cat) | |
cfb96867 | 1093 | if (!Post::v($cat)) { |
1094 | $hidden[$cat] = 1; | |
1095 | $hide[] = $cat; | |
1096 | } | |
e0d7c076 | 1097 | $hide_requests = join(',', $hide); |
00ba8a74 SJ |
1098 | XDB::query('INSERT INTO requests_hidden (uid, hidden_requests) |
1099 | VALUES ({?}, {?}) | |
1100 | ON DUPLICATE KEY UPDATE hidden_requests = VALUES(hidden_requests)', | |
e0d7c076 SJ |
1101 | S::v('uid'), $hide_requests); |
1102 | } elseif ($hide_requests) { | |
1103 | foreach (explode(',', $hide_requests) as $hide_type) | |
cfb96867 | 1104 | $hidden[$hide_type] = true; |
1105 | } | |
1106 | $page->assign('hide_requests', $hidden); | |
74c55fd6 | 1107 | |
90df2530 FB |
1108 | // Update the count of item to validate here... useful in development configuration |
1109 | // where several copies of the site use the same DB, but not the same "dynamic configuration" | |
ebfdf077 FB |
1110 | global $globals; |
1111 | $globals->updateNbValid(); | |
7b094a73 | 1112 | $page->assign('vit', Validate::iterate()); |
e33b29e5 | 1113 | $page->assign('isAdmin', S::admin()); |
86f0a6af | 1114 | } |
e654517d | 1115 | |
32b3ac78 FB |
1116 | function handler_validate_answers(&$page, $action = 'list', $id = null) |
1117 | { | |
46f272fe | 1118 | $page->setTitle('Administration - Réponses automatiques de validation'); |
a7de4ef7 | 1119 | $page->assign('title', 'Gestion des réponses automatiques'); |
e18888f4 | 1120 | $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id'); |
a7de4ef7 | 1121 | $table_editor->describe('category','catégorie',true); |
e18888f4 | 1122 | $table_editor->describe('title','titre',true); |
1123 | $table_editor->describe('answer','texte',false); | |
1124 | $table_editor->apply($page, $action, $id); | |
1125 | } | |
32b3ac78 FB |
1126 | |
1127 | function handler_skins(&$page, $action = 'list', $id = null) | |
1128 | { | |
46f272fe | 1129 | $page->setTitle('Administration - Skins'); |
e7ae7df9 | 1130 | $page->assign('title', 'Gestion des skins'); |
1131 | $table_editor = new PLTableEditor('admin/skins','skins','id'); | |
1132 | $table_editor->describe('name','nom',true); | |
1133 | $table_editor->describe('skin_tpl','nom du template',true); | |
1134 | $table_editor->describe('auteur','auteur',false); | |
1135 | $table_editor->describe('comment','commentaire',true); | |
1136 | $table_editor->describe('date','date',false); | |
1137 | $table_editor->describe('ext','extension du screenshot',false); | |
1138 | $table_editor->apply($page, $action, $id); | |
74c55fd6 | 1139 | } |
669cb0e0 | 1140 | |
32b3ac78 FB |
1141 | function handler_postfix_blacklist(&$page, $action = 'list', $id = null) |
1142 | { | |
46f272fe | 1143 | $page->setTitle('Administration - Postfix : Blacklist'); |
e7ae7df9 | 1144 | $page->assign('title', 'Blacklist de postfix'); |
1145 | $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true); | |
1146 | $table_editor->describe('reject_text','Texte de rejet',true); | |
1147 | $table_editor->describe('email','email',true); | |
1148 | $table_editor->apply($page, $action, $id); | |
74c55fd6 | 1149 | } |
32b3ac78 FB |
1150 | |
1151 | function handler_postfix_whitelist(&$page, $action = 'list', $id = null) | |
1152 | { | |
46f272fe | 1153 | $page->setTitle('Administration - Postfix : Whitelist'); |
e7ae7df9 | 1154 | $page->assign('title', 'Whitelist de postfix'); |
1155 | $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true); | |
1156 | $table_editor->describe('email','email',true); | |
1157 | $table_editor->apply($page, $action, $id); | |
74c55fd6 | 1158 | } |
32b3ac78 FB |
1159 | |
1160 | function handler_mx_broken(&$page, $action = 'list', $id = null) | |
1161 | { | |
46f272fe | 1162 | $page->setTitle('Administration - MX Défaillants'); |
a7de4ef7 | 1163 | $page->assign('title', 'MX Défaillant'); |
ccdbc270 | 1164 | $table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true); |
1165 | $table_editor->describe('host', 'Masque', true); | |
1166 | $table_editor->describe('state', 'Niveau', true); | |
a7de4ef7 | 1167 | $table_editor->describe('text', 'Description du problème', false); |
ccdbc270 | 1168 | $table_editor->apply($page, $action, $id); |
1169 | } | |
32b3ac78 FB |
1170 | |
1171 | function handler_logger_actions(&$page, $action = 'list', $id = null) | |
1172 | { | |
46f272fe | 1173 | $page->setTitle('Administration - Actions'); |
e7ae7df9 | 1174 | $page->assign('title', 'Gestion des actions de logger'); |
6586a74f | 1175 | $table_editor = new PLTableEditor('admin/logger/actions','log_actions','id'); |
a7de4ef7 | 1176 | $table_editor->describe('text','intitulé',true); |
e7ae7df9 | 1177 | $table_editor->describe('description','description',true); |
1178 | $table_editor->apply($page, $action, $id); | |
74c55fd6 | 1179 | } |
32b3ac78 | 1180 | |
8f2104cb FB |
1181 | function handler_downtime(&$page, $action = 'list', $id = null) |
1182 | { | |
46f272fe | 1183 | $page->setTitle('Administration - Coupures'); |
e7ae7df9 | 1184 | $page->assign('title', 'Gestion des coupures'); |
06f4daf9 | 1185 | $table_editor = new PLTableEditor('admin/downtime','downtimes','id'); |
e7ae7df9 | 1186 | $table_editor->describe('debut','date',true); |
a7de4ef7 | 1187 | $table_editor->describe('duree','durée',false); |
1188 | $table_editor->describe('resume','résumé',true); | |
1189 | $table_editor->describe('services','services affectés',true); | |
e7ae7df9 | 1190 | $table_editor->describe('description','description',false); |
1191 | $table_editor->apply($page, $action, $id); | |
74c55fd6 | 1192 | } |
bc0903c7 | 1193 | |
a7fada4f SJ |
1194 | private static function isCountryIncomplete(array &$item) |
1195 | { | |
1196 | $warning = false; | |
1197 | foreach (array('worldRegion', 'country', 'capital', 'phonePrefix', 'licensePlate', 'countryPlain') as $field) { | |
1198 | if ($item[$field] == '') { | |
1199 | $item[$field . '_warning'] = true; | |
1200 | $warning = true; | |
1201 | } | |
1202 | } | |
1203 | if (is_null($item['belongsTo'])) { | |
1204 | foreach (array('nationality', 'nationalityEn') as $field) { | |
1205 | if ($item[$field] == '') { | |
1206 | $item[$field . '_warning'] = true; | |
1207 | $warning = true; | |
1208 | } | |
1209 | } | |
1210 | } | |
1211 | return $warning; | |
1212 | } | |
1213 | ||
846bfc83 SJ |
1214 | private static function updateCountry(array $item) |
1215 | { | |
1216 | XDB::execute('UPDATE geoloc_countries | |
1217 | SET countryPlain = {?} | |
1218 | WHERE iso_3166_1_a2 = {?}', | |
1219 | mb_strtoupper(replace_accent($item['country'])), $item['iso_3166_1_a2']); | |
1220 | } | |
1221 | ||
a7fada4f SJ |
1222 | private static function isLanguageIncomplete(array &$item) |
1223 | { | |
1224 | if ($item['language'] == '') { | |
1225 | $item['language_warning'] = true; | |
1226 | return true; | |
1227 | } | |
1228 | return false; | |
1229 | } | |
1230 | ||
846bfc83 SJ |
1231 | private static function updateLanguage(array $item) {} |
1232 | ||
1233 | function handler_geocoding(&$page, $category = null, $action = null, $id = null) | |
a7fada4f SJ |
1234 | { |
1235 | // Warning, this handler requires the following packages: | |
1236 | // * pkg-isocodes | |
1237 | // * isoquery | |
1238 | ||
1239 | static $properties = array( | |
1240 | 'country' => array( | |
1241 | 'name' => 'pays', | |
1242 | 'isocode' => '3166', | |
1243 | 'table' => 'geoloc_countries', | |
1244 | 'id' => 'iso_3166_1_a2', | |
1245 | 'main_fields' => array('iso_3166_1_a3', 'iso_3166_1_num', 'countryEn'), | |
1246 | 'other_fields' => array('worldRegion', 'country', 'capital', 'nationality', 'nationalityEn', | |
846bfc83 | 1247 | 'phonePrefix', 'phoneFormat', 'licensePlate', 'belongsTo') |
a7fada4f SJ |
1248 | ), |
1249 | 'language' => array( | |
1250 | 'name' => 'langages', | |
1251 | 'isocode' => '639', | |
1252 | 'table' => 'profile_langskill_enum', | |
1253 | 'id' => 'iso_639_2b', | |
1254 | 'main_fields' => array('iso_639_2t', 'iso_639_1', 'language_en'), | |
1255 | 'other_fields' => array('language') | |
1256 | ||
1257 | ) | |
1258 | ); | |
a7fada4f | 1259 | |
846bfc83 | 1260 | if (is_null($category) || !array_key_exists($category, $properties)) { |
a7fada4f SJ |
1261 | pl_redirect('admin'); |
1262 | } | |
1263 | ||
846bfc83 SJ |
1264 | $data = $properties[$category]; |
1265 | ||
1266 | if ($action == 'edit' || $action == 'add') { | |
1267 | $main_fields = array_merge(array($data['id']), $data['main_fields']); | |
1268 | $all_fields = array_merge($main_fields, $data['other_fields']); | |
1269 | ||
1270 | if (is_null($id)) { | |
1271 | if (Post::has('new_id')) { | |
1272 | $id = Post::v('new_id'); | |
1273 | } else { | |
1274 | pl_redirect('admin/geocoding/' . $category); | |
1275 | } | |
1276 | } | |
1277 | ||
1278 | $list = array(); | |
1279 | exec('isoquery --iso=' . $data['isocode'] . ' ' . $id, $list); | |
1280 | if (count($list) == 1) { | |
1281 | $array = explode("\t", $list[0]); | |
1282 | foreach ($main_fields as $i => $field) { | |
1283 | $iso[$field] = $array[$i]; | |
1284 | } | |
1285 | } else { | |
1286 | $iso = array(); | |
1287 | } | |
1288 | ||
1289 | if ($action == 'add') { | |
1290 | if (Post::has('new_id')) { | |
1291 | S::assert_xsrf_token(); | |
1292 | } | |
1293 | ||
1294 | if (count($iso)) { | |
1295 | $item = $iso; | |
1296 | } else { | |
1297 | $item = array($data['id'] => $id); | |
1298 | } | |
1299 | XDB::execute('INSERT INTO ' . $data['table'] . '(' . implode(', ', array_keys($item)) . ') | |
1300 | VALUES ' . XDB::formatArray($item)); | |
1301 | $page->trigSuccess($id . ' a bien été ajouté à la base.'); | |
1302 | } elseif ($action == 'edit') { | |
1303 | if (Post::has('edit')) { | |
1304 | S::assert_xsrf_token(); | |
1305 | ||
1306 | $item = array(); | |
1307 | $set = array(); | |
1308 | foreach ($all_fields as $field) { | |
1309 | $item[$field] = Post::t($field); | |
1310 | $set[] = $field . XDB::format(' = {?}', ($item[$field] ? $item[$field] : null)); | |
1311 | } | |
1312 | XDB::execute('UPDATE ' . $data['table'] . ' | |
1313 | SET ' . implode(', ', $set) . ' | |
1314 | WHERE ' . $data['id'] . ' = {?}', | |
1315 | $id); | |
1316 | call_user_func_array(array('self', 'update' . ucfirst($category)), array($item)); | |
1317 | $page->trigSuccess($id . ' a bien été mis à jour.'); | |
1318 | } elseif (Post::has('del')) { | |
1319 | S::assert_xsrf_token(); | |
1320 | ||
1321 | XDB::execute('DELETE FROM ' . $data['table'] . ' | |
1322 | WHERE ' . $data['id'] . ' = {?}', | |
1323 | $id); | |
1324 | $page->trigSuccessRedirect($id . ' a bien été supprimé.', 'admin/geocoding/' . $category); | |
1325 | } else { | |
1326 | $item = XDB::fetchOneAssoc('SELECT * | |
1327 | FROM ' . $data['table'] . ' | |
1328 | WHERE ' . $data['id'] . ' = {?}', | |
1329 | $id); | |
1330 | } | |
1331 | } | |
1332 | ||
1333 | $page->changeTpl('admin/geocoding_edit.tpl'); | |
1334 | $page->setTitle('Administration - ' . ucfirst($data['name'])); | |
1335 | $page->assign('category', $category); | |
1336 | $page->assign('name', $data['name']); | |
1337 | $page->assign('all_fields', $all_fields); | |
1338 | $page->assign('id', $id); | |
1339 | $page->assign('iso', $iso); | |
1340 | $page->assign('item', $item); | |
1341 | return; | |
1342 | } | |
a7fada4f SJ |
1343 | |
1344 | $page->changeTpl('admin/geocoding.tpl'); | |
1345 | $page->setTitle('Administration - ' . ucfirst($data['name'])); | |
846bfc83 | 1346 | $page->assign('category', $category); |
a7fada4f SJ |
1347 | $page->assign('name', $data['name']); |
1348 | $page->assign('id', $data['id']); | |
1349 | $page->assign('main_fields', $data['main_fields']); | |
1350 | $page->assign('all_fields', array_merge($data['main_fields'], $data['other_fields'])); | |
1351 | ||
1352 | // First build the list provided by the iso codes. | |
1353 | $list = array(); | |
1354 | exec('isoquery --iso=' . $data['isocode'], $list); | |
1355 | ||
1356 | foreach ($list as $key => $item) { | |
1357 | $array = explode("\t", $item); | |
1358 | unset($list[$key]); | |
1359 | $list[$array[0]] = array(); | |
1360 | foreach ($data['main_fields'] as $i => $field) { | |
1361 | $list[$array[0]][$field] = $array[$i + 1]; | |
1362 | } | |
1363 | } | |
1364 | ksort($list); | |
1365 | ||
1366 | // Retrieve all data from the database. | |
1367 | $db_list = XDB::rawFetchAllAssoc('SELECT * | |
1368 | FROM ' . $data['table'] . ' | |
1369 | ORDER BY ' . $data['id'], | |
1370 | $data['id']); | |
1371 | ||
1372 | // Sort both iso and database data into 5 categories: | |
1373 | // $missing: data from the iso list not in the database, | |
1374 | // $non_existing: data from the database not in the iso list, | |
1375 | // $erroneous: data that differ on main fields, | |
1376 | // $incomplete: data with empty fields in the data base, | |
1377 | // $remaining: remaining correct and complete data from the database. | |
1378 | ||
1379 | $missing = $non_existing = $erroneous = $incomplete = $remaining = array(); | |
1380 | foreach (array_keys($list) as $id) { | |
1381 | if (!array_key_exists($id, $db_list)) { | |
1382 | $missing[$id] = $list[$id]; | |
1383 | } | |
1384 | } | |
1385 | ||
1386 | foreach ($db_list as $id => $item) { | |
1387 | if (!array_key_exists($id, $list)) { | |
1388 | $non_existing[$id] = $item; | |
1389 | } else { | |
1390 | $error = false; | |
1391 | foreach ($data['main_fields'] as $field) { | |
1392 | if ($item[$field] != $list[$id][$field]) { | |
1393 | $item[$field . '_error'] = true; | |
1394 | $error = true; | |
1395 | } | |
1396 | } | |
1397 | if ($error == true) { | |
1398 | $erroneous[$id] = $item; | |
846bfc83 | 1399 | } elseif (call_user_func_array(array('self', 'is' . ucfirst($category) . 'Incomplete'), array(&$item))) { |
a7fada4f SJ |
1400 | $incomplete[$id] = $item; |
1401 | } else { | |
1402 | $remaining[$id] = $item; | |
1403 | } | |
1404 | } | |
1405 | } | |
1406 | ||
1407 | $page->assign('lists', array( | |
1408 | 'manquant' => $missing, | |
1409 | 'disparu' => $non_existing, | |
1410 | 'erroné' => $erroneous, | |
1411 | 'incomplet' => $incomplete, | |
1412 | 'restant' => $remaining | |
1413 | )); | |
1414 | } | |
1415 | ||
8338711c FB |
1416 | function handler_accounts(PlPage $page) |
1417 | { | |
1418 | $page->changeTpl('admin/accounts.tpl'); | |
1419 | $page->setTitle('Administration - Comptes'); | |
1420 | $page->addJsLink('password.js'); | |
1421 | ||
1422 | if (Post::has('create_account')) { | |
1423 | S::assert_xsrf_token(); | |
1424 | $firstname = Post::t('firstname'); | |
1425 | $lastname = strtoupper(Post::t('lastname')); | |
e8c61abe | 1426 | $sex = Post::s('sex'); |
8338711c | 1427 | $email = Post::t('email'); |
67cff520 FB |
1428 | $type = Post::s('type'); |
1429 | $login = PlUser::makeHrid($firstname, $lastname, $type); | |
8338711c FB |
1430 | if (!isvalid_email($email)) { |
1431 | $page->trigError("Invalid email address: $email"); | |
1432 | } else if (strlen(Post::s('pwhash')) != 40) { | |
1433 | $page->trigError("Invalid password hash"); | |
1434 | } else { | |
1435 | $full_name = $firstname . ' ' . $lastname; | |
1436 | $directory_name = $lastname . ' ' . $firstname; | |
1437 | XDB::execute("INSERT INTO accounts (hruid, type, state, password, | |
1438 | registration_date, email, full_name, | |
1439 | display_name, sex, directory_name) | |
67cff520 FB |
1440 | VALUES ({?}, {?}, 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?})", |
1441 | $login, $type, Post::s('pwhash'), $email, $full_name, $full_name, $sex, | |
8338711c FB |
1442 | $directory_name); |
1443 | } | |
1444 | } | |
1445 | ||
67cff520 FB |
1446 | $uf = new UserFilter(new UFC_AccountType('ax', 'school', 'fx')); |
1447 | $page->assign('users', $uf->iterUsers()); | |
8338711c FB |
1448 | |
1449 | } | |
1450 | ||
aab2ffdd | 1451 | function handler_account_types(&$page, $action = 'list', $id = null) |
8f2104cb FB |
1452 | { |
1453 | $page->setTitle('Administration - Types de comptes'); | |
1454 | $page->assign('title', 'Gestion des types de comptes'); | |
1455 | $table_editor = new PLTableEditor('admin/account/types', 'account_types', 'type', true); | |
1456 | $table_editor->describe('type', 'Catégorie', true); | |
1457 | $table_editor->describe('perms', 'Permissions associées', true); | |
1458 | $table_editor->apply($page, $action, $id); | |
1459 | } | |
1460 | ||
8f201b69 | 1461 | function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null) |
bc0903c7 | 1462 | { |
84fc72ff | 1463 | if (S::hasAuthToken()) { |
a2b461ce | 1464 | $page->setRssLink('Changement Récents', |
2ab3486b | 1465 | '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::user()->token); |
a2b461ce | 1466 | } |
e61326ed | 1467 | |
3aec1c21 | 1468 | // update wiki perms |
40d428d8 VZ |
1469 | if ($action == 'update') { |
1470 | S::assert_xsrf_token(); | |
1471 | ||
3aec1c21 | 1472 | $perms_read = Post::v('read'); |
8f201b69 | 1473 | $perms_edit = Post::v('edit'); |
3aec1c21 | 1474 | if ($perms_read || $perms_edit) { |
8f201b69 FB |
1475 | foreach ($_POST as $wiki_page => $val) { |
1476 | if ($val == 'on') { | |
1477 | $wp = new PlWikiPage(str_replace(array('_', '/'), '.', $wiki_page)); | |
1478 | if ($wp->setPerms($perms_read ? $perms_read : $wp->readPerms(), | |
1479 | $perms_edit ? $perms_edit : $wp->writePerms())) { | |
1480 | $page->trigSuccess("Permission de la page $wiki_page mises à jour"); | |
1481 | } else { | |
1482 | $page->trigError("Impossible de mettre les permissions de la page $wiki_page à jour"); | |
1483 | } | |
1484 | } | |
3aec1c21 | 1485 | } |
1486 | } | |
8f201b69 FB |
1487 | } else if ($action != 'list' && !empty($wikipage)) { |
1488 | $wp = new PlWikiPage($wikipage); | |
40d428d8 VZ |
1489 | S::assert_xsrf_token(); |
1490 | ||
8f201b69 FB |
1491 | if ($action == 'delete') { |
1492 | if ($wp->delete()) { | |
1493 | $page->trigSuccess("La page ".$wikipage." a été supprimée."); | |
1494 | } else { | |
1495 | $page->trigError("Impossible de supprimer la page ".$wikipage."."); | |
1496 | } | |
1497 | } else if ($action == 'rename' && !empty($wikipage2) && $wikipage != $wikipage2) { | |
1498 | if ($changedLinks = $wp->rename($wikipage2)) { | |
1499 | $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.'; | |
1500 | if (is_numeric($changedLinks)) { | |
1501 | $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.'); | |
1502 | } | |
1503 | $page->trigSuccess($s); | |
1504 | } else { | |
1505 | $page->trigError("Impossible de déplacer la page ".$wikipage); | |
9162f4ed | 1506 | } |
9162f4ed | 1507 | } |
1508 | } | |
74c55fd6 | 1509 | |
8f201b69 | 1510 | $perms = PlWikiPage::permOptions(); |
74c55fd6 | 1511 | |
3aec1c21 | 1512 | // list wiki pages and their perms |
8f201b69 | 1513 | $wiki_pages = PlWikiPage::listPages(); |
3aec1c21 | 1514 | ksort($wiki_pages); |
bc0903c7 | 1515 | $wiki_tree = array(); |
1516 | foreach ($wiki_pages as $file => $desc) { | |
1517 | list($cat, $name) = explode('.', $file); | |
1518 | if (!isset($wiki_tree[$cat])) { | |
1519 | $wiki_tree[$cat] = array(); | |
1520 | } | |
1521 | $wiki_tree[$cat][$name] = $desc; | |
1522 | } | |
1523 | ||
3aec1c21 | 1524 | $page->changeTpl('admin/wiki.tpl'); |
bc0903c7 | 1525 | $page->assign('wiki_pages', $wiki_tree); |
3aec1c21 | 1526 | $page->assign('perms_opts', $perms); |
1527 | } | |
5480a216 | 1528 | |
1529 | function handler_ipwatch(&$page, $action = 'list', $ip = null) | |
eaf30d86 | 1530 | { |
5480a216 | 1531 | $page->changeTpl('admin/ipwatcher.tpl'); |
eaf30d86 | 1532 | |
5480a216 | 1533 | $states = array('safe' => 'Ne pas surveiller', |
c339246f | 1534 | 'unsafe' => 'Surveiller les inscriptions', |
a7de4ef7 | 1535 | 'dangerous' => 'Surveiller tous les accès', |
5480a216 | 1536 | 'ban' => 'Bannir cette adresse'); |
1537 | $page->assign('states', $states); | |
1538 | ||
1539 | switch (Post::v('action')) { | |
e61326ed | 1540 | case 'create': |
5480a216 | 1541 | if (trim(Post::v('ipN')) != '') { |
40d428d8 | 1542 | S::assert_xsrf_token(); |
61c98f4b FB |
1543 | Xdb::execute('INSERT IGNORE INTO ip_watch (ip, mask, state, detection, last, uid, description) |
1544 | VALUES ({?}, {?}, {?}, CURDATE(), NOW(), {?}, {?})', | |
1545 | ip_to_uint(trim(Post::v('ipN'))), ip_to_uint(trim(Post::v('maskN'))), | |
1546 | Post::v('stateN'), S::i('uid'), Post::v('descriptionN')); | |
eaf30d86 PH |
1547 | }; |
1548 | break; | |
1549 | ||
e61326ed | 1550 | case 'edit': |
40d428d8 | 1551 | S::assert_xsrf_token(); |
eaf30d86 | 1552 | Xdb::execute('UPDATE ip_watch |
61c98f4b | 1553 | SET state = {?}, last = NOW(), uid = {?}, description = {?}, mask = {?} |
9797734d | 1554 | WHERE ip = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), |
61c98f4b | 1555 | ip_to_uint(Post::v('maskN')), ip_to_uint(Post::v('ipN'))); |
5480a216 | 1556 | break; |
eaf30d86 | 1557 | |
e61326ed | 1558 | default: |
5480a216 | 1559 | if ($action == 'delete' && !is_null($ip)) { |
40d428d8 VZ |
1560 | S::assert_xsrf_token(); |
1561 | Xdb::execute('DELETE FROM ip_watch WHERE ip = {?}', ip_to_uint($ip)); | |
5480a216 | 1562 | } |
1563 | } | |
1564 | if ($action != 'create' && $action != 'edit') { | |
1565 | $action = 'list'; | |
1566 | } | |
1567 | $page->assign('action', $action); | |
1568 | ||
1569 | if ($action == 'list') { | |
9797734d FB |
1570 | $sql = "SELECT w.ip, IF(s.ip IS NULL, |
1571 | IF(w.ip = s2.ip, s2.host, s2.forward_host), | |
1572 | IF(w.ip = s.ip, s.host, s.forward_host)), | |
32b3ac78 | 1573 | w.mask, w.detection, w.state, a.hruid |
fe13bc1d | 1574 | FROM ip_watch AS w |
6586a74f FB |
1575 | LEFT JOIN log_sessions AS s ON (s.ip = w.ip) |
1576 | LEFT JOIN log_sessions AS s2 ON (s2.forward_ip = w.ip) | |
fe13bc1d | 1577 | LEFT JOIN accounts AS a ON (a.uid = s.uid) |
32b3ac78 FB |
1578 | GROUP BY w.ip, a.hruid |
1579 | ORDER BY w.state, w.ip, a.hruid"; | |
5480a216 | 1580 | $it = Xdb::iterRow($sql); |
1581 | ||
1582 | $table = array(); | |
1583 | $props = array(); | |
90c614cd | 1584 | while (list($ip, $host, $mask, $date, $state, $hruid) = $it->next()) { |
9797734d | 1585 | $ip = uint_to_ip($ip); |
61c98f4b | 1586 | $mask = uint_to_ip($mask); |
5480a216 | 1587 | if (count($props) == 0 || $props['ip'] != $ip) { |
1588 | if (count($props) > 0) { | |
1589 | $table[] = $props; | |
1590 | } | |
1591 | $props = array('ip' => $ip, | |
61c98f4b | 1592 | 'mask' => $mask, |
5480a216 | 1593 | 'host' => $host, |
1594 | 'detection' => $date, | |
1595 | 'state' => $state, | |
90c614cd | 1596 | 'users' => array($hruid)); |
5480a216 | 1597 | } else { |
90c614cd | 1598 | $props['users'][] = $hruid; |
5480a216 | 1599 | } |
1600 | } | |
1601 | if (count($props) > 0) { | |
1602 | $table[] = $props; | |
1603 | } | |
1604 | $page->assign('table', $table); | |
1605 | } elseif ($action == 'edit') { | |
61c98f4b | 1606 | $sql = "SELECT w.detection, w.state, w.last, w.description, w.mask, |
32b3ac78 | 1607 | a1.hruid AS edit, a2.hruid AS hruid, s.host |
fe13bc1d FB |
1608 | FROM ip_watch AS w |
1609 | LEFT JOIN accounts AS a1 ON (a1.uid = w.uid) | |
6586a74f | 1610 | LEFT JOIN log_sessions AS s ON (w.ip = s.ip) |
fe13bc1d | 1611 | LEFT JOIN accounts AS a2 ON (a2.uid = s.uid) |
5480a216 | 1612 | WHERE w.ip = {?} |
32b3ac78 FB |
1613 | GROUP BY a2.hruid |
1614 | ORDER BY a2.hruid"; | |
9797734d | 1615 | $it = Xdb::iterRow($sql, ip_to_uint($ip)); |
5480a216 | 1616 | |
1617 | $props = array(); | |
90c614cd | 1618 | while (list($detection, $state, $last, $description, $mask, $edit, $hruid, $host) = $it->next()) { |
5480a216 | 1619 | if (count($props) == 0) { |
1620 | $props = array('ip' => $ip, | |
61c98f4b | 1621 | 'mask' => uint_to_ip($mask), |
5480a216 | 1622 | 'host' => $host, |
1623 | 'detection' => $detection, | |
1624 | 'state' => $state, | |
1625 | 'last' => $last, | |
1626 | 'description' => $description, | |
1627 | 'edit' => $edit, | |
90c614cd | 1628 | 'users' => array($hruid)); |
5480a216 | 1629 | } else { |
90c614cd | 1630 | $props['users'][] = $hruid; |
5480a216 | 1631 | } |
1632 | } | |
1633 | $page->assign('ip', $props); | |
1634 | } | |
1635 | } | |
eaf30d86 | 1636 | |
04148a2c | 1637 | function handler_icons(&$page) |
f141945d | 1638 | { |
1639 | $page->changeTpl('admin/icons.tpl'); | |
1640 | $dh = opendir('../htdocs/images/icons'); | |
1641 | if (!$dh) { | |
a7d35093 | 1642 | $page->trigError('Dossier des icones introuvables.'); |
f141945d | 1643 | } |
1644 | $icons = array(); | |
1645 | while (($file = readdir($dh)) !== false) { | |
1646 | if (strlen($file) > 4 && substr($file,-4) == '.gif') { | |
1647 | array_push($icons, substr($file, 0, -4)); | |
1648 | } | |
1649 | } | |
1650 | sort($icons); | |
1651 | $page->assign('icons', $icons); | |
04148a2c | 1652 | } |
fd1ce8c5 | 1653 | |
8338711c | 1654 | function handler_account_watch(&$page) |
fd1ce8c5 FB |
1655 | { |
1656 | $page->changeTpl('admin/accounts.tpl'); | |
32b3ac78 FB |
1657 | $page->assign('disabled', XDB::iterator('SELECT a.hruid, FIND_IN_SET(\'watch\', a.flags) AS watch, |
1658 | a.state = \'disabled\' AS disabled, a.comment | |
1659 | FROM accounts AS a | |
1660 | WHERE a.state = \'disabled\' OR FIND_IN_SET(\'watch\', a.flags) | |
1661 | ORDER BY a.hruid')); | |
1662 | $page->assign('admins', XDB::iterator('SELECT a.hruid | |
1663 | FROM accounts AS a | |
1664 | WHERE a.is_admin | |
1665 | ORDER BY a.hruid')); | |
fd1ce8c5 | 1666 | } |
4d336f59 SJ |
1667 | |
1668 | function handler_jobs(&$page, $id = -1) | |
1669 | { | |
1670 | $page->changeTpl('admin/jobs.tpl'); | |
1671 | ||
1672 | if (Env::has('search')) { | |
308bbdb0 SJ |
1673 | $res = XDB::query("SELECT id, name, acronym |
1674 | FROM profile_job_enum | |
1675 | WHERE name LIKE CONCAT('%', {?}, '%') OR acronym LIKE CONCAT('%', {?}, '%')", | |
4d336f59 SJ |
1676 | Env::t('job'), Env::t('job')); |
1677 | ||
1678 | if ($res->numRows() <= 20) { | |
1679 | $page->assign('jobs', $res->fetchAllAssoc()); | |
1680 | } else { | |
1681 | $page->trigError("Il y a trop d'entreprises correspondant à ton choix. Affine-le !"); | |
1682 | } | |
1683 | ||
1684 | $page->assign('askedJob', Env::v('job')); | |
1685 | return; | |
1686 | } | |
1687 | ||
1688 | if (Env::has('edit')) { | |
1689 | S::assert_xsrf_token(); | |
1690 | $selectedJob = Env::has('selectedJob'); | |
1691 | ||
0b6c8b36 | 1692 | Phone::deletePhones(0, Phone::LINK_COMPANY, $id); |
781a24bc | 1693 | Address::deleteAddresses(null, Address::LINK_COMPANY, $id); |
4d336f59 | 1694 | if (Env::has('change')) { |
e954a945 SJ |
1695 | if (Env::has('newJobId') && Env::i('newJobId') > 0) { |
1696 | XDB::execute('UPDATE profile_job | |
1697 | SET jobid = {?} | |
1698 | WHERE jobid = {?}', | |
1699 | Env::i('newJobId'), $id); | |
1700 | XDB::execute('DELETE FROM profile_job_enum | |
1701 | WHERE id = {?}', | |
1702 | $id); | |
1703 | ||
1704 | $page->trigSuccess("L'entreprise a bien été remplacée."); | |
1705 | } else { | |
1706 | $page->trigError("L'entreprise n'a pas été remplacée car l'identifiant fourni n'est pas valide."); | |
1707 | } | |
4d336f59 SJ |
1708 | } else { |
1709 | XDB::execute('UPDATE profile_job_enum | |
1710 | SET name = {?}, acronym = {?}, url = {?}, email = {?}, | |
1711 | NAF_code = {?}, AX_code = {?}, holdingid = {?} | |
1712 | WHERE id = {?}', | |
1713 | Env::t('name'), Env::t('acronym'), Env::t('url'), Env::t('email'), | |
e4fb72eb SJ |
1714 | (Env::t('NAF_code') == 0 ? null : Env::t('NAF_code')), |
1715 | (Env::i('AX_code') == 0 ? null : Env::t('AX_code')), | |
1716 | (Env::i('holdingId') == 0 ? null : Env::t('holdingId')), $id); | |
4d336f59 | 1717 | |
0b6c8b36 SJ |
1718 | $phone = new Phone(array('display' => Env::v('tel'), 'link_id' => $id, 'id' => 0, 'type' => 'fixed', |
1719 | 'link_type' => Phone::LINK_COMPANY, 'pub' => 'public')); | |
1720 | $fax = new Phone(array('display' => Env::v('fax'), 'link_id' => $id, 'id' => 1, 'type' => 'fax', | |
1721 | 'link_type' => Phone::LINK_COMPANY, 'pub' => 'public')); | |
c32bed90 | 1722 | $address = new Address(array('jobid' => $id, 'type' => Address::LINK_COMPANY, 'text' => Env::t('address'))); |
0b6c8b36 SJ |
1723 | $phone->save(); |
1724 | $fax->save(); | |
a710dfd7 | 1725 | $address->save(); |
63596a65 | 1726 | |
4d336f59 SJ |
1727 | $page->trigSuccess("L'entreprise a bien été mise à jour."); |
1728 | } | |
1729 | } | |
1730 | ||
1731 | if (!Env::has('change') && $id != -1) { | |
63596a65 SJ |
1732 | $res = XDB::query("SELECT e.id, e.name, e.acronym, e.url, e.email, e.NAF_code, e.AX_code, |
1733 | h.id AS holdingId, h.name AS holdingName, h.acronym AS holdingAcronym, | |
1734 | t.display_tel AS tel, f.display_tel AS fax, a.text AS address | |
1735 | FROM profile_job_enum AS e | |
1736 | LEFT JOIN profile_job_enum AS h ON (e.holdingid = h.id) | |
9483a7c7 SJ |
1737 | LEFT JOIN profile_phones AS t ON (t.pid = e.id AND t.link_type = 'hq' AND t.tel_id = 0) |
1738 | LEFT JOIN profile_phones AS f ON (f.pid = e.id AND f.link_type = 'hq' AND f.tel_id = 1) | |
63596a65 SJ |
1739 | LEFT JOIN profile_addresses AS a ON (a.jobid = e.id AND a.type = 'hq') |
1740 | WHERE e.id = {?}", | |
4d336f59 SJ |
1741 | $id); |
1742 | ||
1743 | if ($res->numRows() == 0) { | |
1744 | $page->trigError('Auncune entreprise ne correspond à cet identifiant.'); | |
1745 | } else { | |
1746 | $page->assign('selectedJob', $res->fetchOneAssoc()); | |
1747 | } | |
1748 | } | |
1749 | } | |
4d5946ac SJ |
1750 | |
1751 | function handler_profile(&$page) | |
1752 | { | |
1753 | $page->changeTpl('admin/profile.tpl'); | |
1754 | ||
1755 | if (Post::has('checked')) { | |
1756 | S::assert_xsrf_token(); | |
1757 | $res = XDB::iterator('SELECT DISTINCT(pm.pid), pd.public_name | |
1758 | FROM profile_modifications AS pm | |
1759 | INNER JOIN profile_display AS pd ON (pm.pid = pd.pid) | |
1760 | WHERE pm.type = \'self\''); | |
1761 | ||
1762 | while ($profile = $res->next()) { | |
1763 | if (Post::has('checked_' . $profile['pid'])) { | |
1764 | XDB::execute('DELETE FROM profile_modifications | |
1765 | WHERE type = \'self\' AND pid = {?}', $profile['pid']); | |
1766 | ||
1767 | $page->trigSuccess('Profil de ' . $profile['public_name'] . ' vérifié.'); | |
1768 | } | |
1769 | } | |
1770 | } | |
1771 | ||
1772 | $res = XDB::iterator('SELECT p.hrpid, pm.pid, pd.directory_name, GROUP_CONCAT(pm.field SEPARATOR \', \') AS field | |
1773 | FROM profile_modifications AS pm | |
1774 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
1775 | INNER JOIN profile_display AS pd ON (pm.pid = pd.pid) | |
1776 | WHERE pm.type = \'self\' | |
1777 | GROUP BY pd.directory_name | |
1778 | ORDER BY pd.directory_name'); | |
1779 | $page->assign('updates', $res); | |
1780 | } | |
86f0a6af | 1781 | } |
1782 | ||
a7de4ef7 | 1783 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
86f0a6af | 1784 | ?> |