Table editor fills the new entry form with the default values of the fields
[platal.git] / modules / xnetgrp.php
CommitLineData
ae7bb180 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
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
ef7c8560 22function get_infos($email)
23{
24 global $globals;
25 // look for uid instead of email if numeric
ed21e24a 26 $field = is_numeric($email) ? 'uid' : 'email';
ef7c8560 27
28 if ($field == 'email') {
29 $email = strtolower($email);
30 if (strpos($email, '@') === false) {
31 $email .= '@m4x.org';
32 }
33 list($mbox,$dom) = explode('@', $email);
34 }
35
08cce2ff 36 $res = XDB::query(
dc2073c3 37 "SELECT uid, nom, prenom, email, email AS email2, perms='admin', origine, sexe
ef7c8560 38 FROM groupex.membres
39 WHERE $field = {?} AND asso_id = {?}", $email, $globals->asso('id'));
40
41 if ($res->numRows()) {
dc2073c3 42 $user = $res->fetchOneAssoc();
43 if ($user['origine'] == 'X') {
44 $res = XDB::query("SELECT nom, prenom, promo, FIND_IN_SET(flags, 'femme') AS sexe
45 FROM auth_user_md5
46 WHERE user_id = {?}", $user['uid']);
47 $user = array_merge($user, $res->fetchOneAssoc());
48 }
49 return $user;
ef7c8560 50 } elseif ($dom == 'polytechnique.org' || $dom == 'm4x.org') {
08cce2ff 51 $res = XDB::query(
ef7c8560 52 "SELECT user_id AS uid, u.promo,
53 IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom,
54 u.prenom, b.alias,
55 CONCAT(b.alias, '@m4x.org') AS email,
56 CONCAT(b.alias, '@polytechnique.org') AS email2,
dc2073c3 57 m.perms='admin' AS perms, m.origine,
b94c80bd 58 FIND_IN_SET(u.flags, 'femme') AS sexe
ef7c8560 59 FROM auth_user_md5 AS u
60 INNER JOIN aliases AS a ON ( u.user_id = a.id AND a.type != 'homonyme' )
61 INNER JOIN aliases AS b ON ( u.user_id = b.id AND b.type = 'a_vie' )
62 INNER JOIN groupex.membres AS m ON ( m.uid = u.user_id AND asso_id={?})
63 WHERE a.alias = {?} AND u.user_id < 50000", $globals->asso('id'), $mbox);
64 return $res->fetchOneAssoc();
65 }
66
67 return null;
68}
69
70
ae7bb180 71class XnetGrpModule extends PLModule
72{
73 function handlers()
74 {
75 return array(
5e193297 76 '%grp' => $this->make_hook('index', AUTH_PUBLIC),
77 '%grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC),
78 '%grp/logo' => $this->make_hook('logo', AUTH_PUBLIC),
79 '%grp/edit' => $this->make_hook('edit', AUTH_MDP),
80 '%grp/mail' => $this->make_hook('mail', AUTH_MDP),
81 '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP),
82 '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP),
28929cf0 83 '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP),
5e193297 84 '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP),
4e310c61 85
d1ebc57a 86 '%grp/admin/annuaire'
4e310c61 87 => $this->make_hook('admin_annuaire', AUTH_MDP),
ef7c8560 88
d1ebc57a 89 '%grp/member'
ef7c8560 90 => $this->make_hook('admin_member', AUTH_MDP),
d1ebc57a 91 '%grp/member/new'
ef7c8560 92 => $this->make_hook('admin_member_new', AUTH_MDP),
dc2073c3 93 '%grp/member/new/ajax'
94 => $this->make_hook('admin_member_new_ajax', AUTH_MDP, '', NO_AUTH),
d1ebc57a 95 '%grp/member/del'
ef7c8560 96 => $this->make_hook('admin_member_del', AUTH_MDP),
24bcf50c 97
98 '%grp/rss' => $this->make_hook('rss', AUTH_PUBLIC),
99 '%grp/announce/new' => $this->make_hook('edit_announce', AUTH_MDP),
100 '%grp/announce/edit' => $this->make_hook('edit_announce', AUTH_MDP),
101 '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_MDP),
ae7bb180 102 );
103 }
104
2e94d2b8 105 function handler_index(&$page, $arg = null)
ae7bb180 106 {
24bcf50c 107 global $globals, $platal;
ae7bb180 108
2e94d2b8 109 if (!is_null($arg)) {
ae7bb180 110 return PL_NOT_FOUND;
111 }
112
d24c8a11 113 new_group_open_page('xnet/groupe/asso.tpl');
ae7bb180 114
24bcf50c 115 if (S::logged()) {
116 if (Env::has('read')) {
117 XDB::query('DELETE r.*
118 FROM groupex.announces_read AS r
119 INNER JOIN groupex.announces AS a ON a.id = r.announce_id
120 WHERE peremption < CURRENT_DATE()');
121 XDB::query('INSERT INTO groupex.announces_read
122 VALUES ({?}, {?})',
123 Env::i('read'), S::i('uid'));
124 pl_redirect("");
125 }
126 if (Env::has('unread')) {
127 XDB::query('DELETE FROM groupex.announces_read
128 WHERE announce_id={?} AND user_id={?}',
129 Env::i('unread'), S::i('uid'));
130 pl_redirect("#art" . Env::i('unread'));
131 }
132 $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife
133 FROM groupex.announces AS a
134 INNER JOIN auth_user_md5 AS u USING(user_id)
135 INNER JOIN aliases AS l ON (u.user_id = l.id AND l.type = 'a_vie')
136 LEFT JOIN groupex.announces_read AS r ON (r.user_id = {?} AND r.announce_id = a.id)
137 WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
138 AND (promo_min = 0 OR promo_min <= {?})
139 AND (promo_max = 0 OR promo_max >= {?})
140 AND r.announce_id IS NULL
141 ORDER BY a.peremption",
142 S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo'));
143 $index = XDB::iterator("SELECT a.id, a.titre, r.user_id IS NULL AS nonlu
144 FROM groupex.announces AS a
145 LEFT JOIN groupex.announces_read AS r ON (a.id = r.announce_id AND r.user_id = {?})
146 WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
147 AND (promo_min = 0 OR promo_min <= {?})
148 AND (promo_max = 0 OR promo_max >= {?})
149 ORDER BY a.peremption",
150 S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo'));
151 $page->assign('article_index', $index);
152 } else {
153 $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo
154 FROM groupex.announces AS a
155 INNER JOIN auth_user_md5 AS u USING(user_id)
156 WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
2a557a09 157 AND FIND_IN_SET(a.flags, 'public')",
24bcf50c 158 $globals->asso('id'));
159 }
160
161 if (!S::has('core_rss_hash')) {
162 $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News publiques",
163 "rss/rss.xml");
164 } else {
165 $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News",
166 'rss/'.S::v('forlife') .'/'.S::v('core_rss_hash').'/rss.xml');
167 }
168
169 require_once('url_catcher.inc.php');
170 $page->register_modifier('url_catcher', 'url_catcher');
171 $page->assign('articles', $arts);
172
ae7bb180 173 $page->assign('asso', $globals->asso());
174 }
dd798f38 175
176 function handler_logo(&$page)
177 {
178 global $globals;
179
08cce2ff 180 $res = XDB::query("SELECT logo, logo_mime
24bcf50c 181 FROM groupex.asso WHERE id = {?}",
182 $globals->asso('id'));
dd798f38 183 list($logo, $logo_mime) = $res->fetchOneRow();
184
185 if (!empty($logo)) {
186 header("Content-type: $mime");
187 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
188 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
189 header('Cache-Control: no-cache, must-revalidate');
190 header('Pragma: no-cache');
191 echo $logo;
192 } else {
193 header('Content-type: image/jpeg');
194 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
195 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
196 header('Cache-Control: no-cache, must-revalidate');
197 header('Pragma: no-cache');
831fae47 198 readfile(dirname(__FILE__).'/../htdocs/images/dflt_carre.jpg');
dd798f38 199 }
200
201 exit;
202 }
2e94d2b8 203
204 function handler_edit(&$page)
205 {
206 global $globals;
207
208 new_groupadmin_page('xnet/groupe/edit.tpl');
209
210 if (Post::has('submit')) {
cab08090 211 if (S::has_perms()) {
5e2307dc 212 if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) {
c9110c6c 213 $page->trig("le domaine doit être un FQDN (aucune modif effectuée) !!!");
214 return;
2e94d2b8 215 }
08cce2ff 216 XDB::execute(
2e94d2b8 217 "UPDATE groupex.asso
218 SET nom={?}, diminutif={?}, cat={?}, dom={?},
219 descr={?}, site={?}, mail={?}, resp={?},
220 forum={?}, mail_domain={?}, ax={?}, pub={?},
221 sub_url={?}, inscriptible={?}
222 WHERE id={?}",
5e2307dc 223 Post::v('nom'), Post::v('diminutif'),
224 Post::v('cat'), Post::i('dom'),
225 Post::v('descr'), Post::v('site'),
226 Post::v('mail'), Post::v('resp'),
227 Post::v('forum'), Post::v('mail_domain'),
2e94d2b8 228 Post::has('ax'), Post::has('pub')?'private':'public',
5e2307dc 229 Post::v('sub_url'), Post::v('inscriptible'),
2e94d2b8 230 $globals->asso('id'));
5e2307dc 231 if (Post::v('mail_domain')) {
08cce2ff 232 XDB::execute('INSERT INTO virtual_domains (domain) VALUES({?})',
5e2307dc 233 Post::v('mail_domain'));
2e94d2b8 234 }
235 } else {
08cce2ff 236 XDB::execute(
2e94d2b8 237 "UPDATE groupex.asso
238 SET descr={?}, site={?}, mail={?}, resp={?},
239 forum={?}, ax={?}, pub= {?}, sub_url={?}
240 WHERE id={?}",
5e2307dc 241 Post::v('descr'), Post::v('site'),
242 Post::v('mail'), Post::v('resp'),
243 Post::v('forum'), Post::has('ax'),
2e94d2b8 244 Post::has('pub')?'private':'public',
5e2307dc 245 Post::v('sub_url'), $globals->asso('id'));
2e94d2b8 246 }
247
248 if ($_FILES['logo']['name']) {
249 $logo = file_get_contents($_FILES['logo']['tmp_name']);
250 $mime = $_FILES['logo']['type'];
08cce2ff 251 XDB::execute('UPDATE groupex.asso
2e94d2b8 252 SET logo={?}, logo_mime={?}
253 WHERE id={?}', $logo, $mime,
254 $globals->asso('id'));
255 }
256
5e2307dc 257 pl_redirect('../'.Post::v('diminutif', $globals->asso('diminutif')).'/edit');
2e94d2b8 258 }
259
cab08090 260 if (S::has_perms()) {
08cce2ff 261 $dom = XDB::iterator('SELECT * FROM groupex.dom ORDER BY nom');
2e94d2b8 262 $page->assign('dom', $dom);
263 $page->assign('super', true);
264 }
265 }
266
479d2787 267 function handler_mail(&$page)
268 {
269 global $globals;
270
479d2787 271 new_groupadmin_page('xnet/groupe/mail.tpl');
9bb8bf21 272 $mmlist = new MMList(S::v('uid'), S::v('password'),
273 $globals->asso('mail_domain'));
274 $page->assign('listes', $mmlist->get_lists());
479d2787 275
276 if (Post::has('send')) {
5e2307dc 277 $from = Post::v('from');
278 $sujet = Post::v('sujet');
279 $body = Post::v('body');
479d2787 280
5e2307dc 281 $mls = array_keys(Env::v('ml', array()));
479d2787 282
283 require_once 'xnet/mail.inc.php';
9bb8bf21 284 $tos = get_all_redirects(Post::has('membres'), $mls, $mmlist);
5e2307dc 285 send_xnet_mails($from, $sujet, $body, $tos, Post::v('replyto'));
ef7c8560 286 $page->kill("Mail envoyé !");
479d2787 287 $page->assign('sent', true);
288 }
289 }
290
2e94d2b8 291 function handler_annuaire(&$page)
292 {
293 global $globals;
d24c8a11 294 new_annu_page('xnet/groupe/annuaire.tpl');
2e94d2b8 295
e02ecfce 296 $sort = Env::v('order');
5e2307dc 297 switch (Env::v('order')) {
2e94d2b8 298 case 'promo' : $group = 'promo'; $tri = 'promo_o DESC, nom, prenom'; break;
299 case 'promo_inv': $group = 'promo'; $tri = 'promo_o, nom, prenom'; break;
300 case 'alpha_inv': $group = 'initiale'; $tri = 'nom DESC, prenom DESC, promo'; break;
e02ecfce 301 default : $group = 'initiale'; $tri = 'nom, prenom, promo'; $sort = 'alpha';
2e94d2b8 302 }
e02ecfce 303 $page->assign('sort', $sort);
2e94d2b8 304
305 if ($group == 'initiale')
08cce2ff 306 $res = XDB::iterRow(
2e94d2b8 307 'SELECT UPPER(SUBSTRING(
dc2073c3 308 IF(m.origine="X", IF(u.nom_usage<>"", u.nom_usage, u.nom),m.nom),
2e94d2b8 309 1, 1)) as letter, COUNT(*)
310 FROM groupex.membres AS m
311 LEFT JOIN auth_user_md5 AS u ON ( u.user_id = m.uid )
312 WHERE asso_id = {?}
313 GROUP BY letter
314 ORDER BY letter', $globals->asso('id'));
315 else
08cce2ff 316 $res = XDB::iterRow(
ef7c8560 317 'SELECT IF(m.origine="X",u.promo,"extérieur") AS promo,
2e94d2b8 318 COUNT(*), IF(m.origine="X",u.promo,"") AS promo_o
319 FROM groupex.membres AS m
320 LEFT JOIN auth_user_md5 AS u ON ( u.user_id = m.uid )
321 WHERE asso_id = {?}
322 GROUP BY promo
323 ORDER BY promo_o DESC', $globals->asso('id'));
324
325 $alphabet = array();
326 $nb_tot = 0;
327 while (list($char, $nb) = $res->next()) {
328 $alphabet[] = $char;
329 $nb_tot += $nb;
5e2307dc 330 if (Env::has($group) && $char == strtoupper(Env::v($group))) {
2e94d2b8 331 $tot = $nb;
332 }
333 }
334 $page->assign('group', $group);
5e2307dc 335 $page->assign('request_group', Env::v($group));
f2900e25 336 $page->assign('only_admin', Env::has('admin'));
2e94d2b8 337 $page->assign('alphabet', $alphabet);
338 $page->assign('nb_tot', $nb_tot);
339
5e2307dc 340 $ofs = Env::i('offset');
341 $tot = Env::v($group) ? $tot : $nb_tot;
2e94d2b8 342 $nbp = intval(($tot-1)/NB_PER_PAGE);
343 $links = array();
344 if ($ofs) {
ef7c8560 345 $links['précédent'] = $ofs-1;
2e94d2b8 346 }
347 for ($i = 0; $i <= $nbp; $i++) {
348 $links[(string)($i+1)] = $i;
349 }
350 if ($ofs < $nbp) {
351 $links['suivant'] = $ofs+1;
352 }
353 if (count($links)>1) {
354 $page->assign('links', $links);
355 }
356
357 $ini = '';
358 if (Env::has('initiale')) {
359 $ini = 'AND IF(m.origine="X",
360 IF(u.nom_usage<>"", u.nom_usage, u.nom),
5e2307dc 361 m.nom) LIKE "'.addslashes(Env::v('initiale')).'%"';
2e94d2b8 362 } elseif (Env::has('promo')) {
ef7c8560 363 $ini = 'AND IF(m.origine="X", u.promo, "extérieur") = "'
5e2307dc 364 .addslashes(Env::v('promo')).'"';
f2900e25 365 } elseif (Env::has('admin')) {
366 $ini = 'AND m.perms = "admin"';
2e94d2b8 367 }
368
08cce2ff 369 $ann = XDB::iterator(
2e94d2b8 370 "SELECT IF(m.origine='X',IF(u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom,
371 IF(m.origine='X',u.prenom,m.prenom) AS prenom,
ef7c8560 372 IF(m.origine='X',u.promo,'extérieur') AS promo,
2e94d2b8 373 IF(m.origine='X',u.promo,'') AS promo_o,
dc2073c3 374 IF(m.origine='X' AND u.perms != 'pending',a.alias,m.email) AS email,
0cc4c07d 375 IF(m.origine='X',FIND_IN_SET('femme', u.flags), m.sexe) AS femme,
2e94d2b8 376 m.perms='admin' AS admin,
377 m.origine='X' AS x,
dc2073c3 378 u.perms!='pending' AS inscrit,
2e94d2b8 379 m.uid
380 FROM groupex.membres AS m
381 LEFT JOIN auth_user_md5 AS u ON ( u.user_id = m.uid )
382 LEFT JOIN aliases AS a ON ( a.id = m.uid AND a.type='a_vie' )
383 WHERE m.asso_id = {?} $ini
dc2073c3 384 AND (m.origine = 'ext' OR u.perms != 'pending' OR m.email IS NOT NULL)
2e94d2b8 385 ORDER BY $tri
386 LIMIT {?},{?}", $globals->asso('id'), $ofs*NB_PER_PAGE, NB_PER_PAGE);
2e94d2b8 387 $page->assign('ann', $ann);
388 }
4e310c61 389
28929cf0 390 function handler_trombi(&$page, $num = 1)
391 {
392 global $globals;
d24c8a11 393 new_annu_page('xnet/groupe/trombi.tpl');
e02a82bc 394
28929cf0 395 $page->assign('urlmainsite', "https://www.polytechnique.org/");
396 $trombi = new Trombi(array($this, '_trombi_getlist'));
397 $trombi->hidePromo();
398 $trombi->setAdmin();
399 $page->assign_by_ref('trombi', $trombi);
400 }
401
402 function _trombi_getlist($offset, $limit)
403 {
404 global $globals;
405 $where = "WHERE m.asso_id= '".addslashes($globals->asso('id'))."'";
406
407 $res = XDB::query(
408 "SELECT COUNT(*)
409 FROM auth_user_md5 AS u
410 RIGHT JOIN photo AS p ON u.user_id=p.uid
411 INNER JOIN groupex.membres AS m ON (m.uid = u.user_id)
412 $where");
413 $pnb = $res->fetchOneCell();
414
415 $res = XDB::query("SELECT promo, user_id, a.alias AS forlife,
416 IF (nom_usage='', u.nom, nom_usage) AS nom, u.prenom
417 FROM photo AS p
418 INNER JOIN auth_user_md5 AS u ON u.user_id=p.uid
419 INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' )
420 INNER JOIN groupex.membres AS m ON (m.uid = u.user_id)
421 $where
422 ORDER BY promo, u.nom, u.prenom LIMIT {?}, {?}", $offset*$limit, $limit);
423
424 return array($pnb, $res->fetchAllAssoc());
425 }
426
917c4d11 427 function handler_vcard(&$page, $photos = null)
5e193297 428 {
429 global $globals;
430
431 if (($globals->asso('pub') == 'public' && is_member()) || may_update()) {
432 $res = XDB::query('SELECT uid
433 FROM groupex.membres
434 WHERE asso_id = {?}', $globals->asso('id'));
435 require_once('vcard.inc.php');
917c4d11 436 $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom'));
5e193297 437 $vcard->do_page($page);
438 } else {
439 return PL_NOTALLOWED;
440 }
441 }
442
fdf0200a 443 function handler_subscribe(&$page, $u = null)
444 {
c8faf82a 445 global $globals;
446
d24c8a11 447 new_group_open_page('xnet/groupe/inscrire.tpl');
fdf0200a 448
449 if (!$globals->asso('inscriptible'))
ef7c8560 450 $page->kill("Il n'est pas possible de s'inscire en ligne à ce "
451 ."groupe. Essaie de joindre le contact indiqué "
452 ."sur la page de présentation.");
fdf0200a 453
454 if (!is_null($u) && may_update()) {
455 $page->assign('u', $u);
08cce2ff 456 $res = XDB::query("SELECT nom, prenom, promo, user_id
fdf0200a 457 FROM auth_user_md5 AS u
458 INNER JOIN aliases AS al ON (al.id = u.user_id
459 AND al.type != 'liste')
460 WHERE al.alias = {?}", $u);
461
462 if (list($nom, $prenom, $promo, $uid) = $res->fetchOneRow()) {
08cce2ff 463 $res = XDB::query("SELECT COUNT(*)
fdf0200a 464 FROM groupex.membres AS m
465 INNER JOIN aliases AS a ON (m.uid = a.id
466 AND a.type != 'homonyme')
467 WHERE a.alias = {?} AND m.asso_id = {?}",
468 $u, $globals->asso('id'));
469 $n = $res->fetchOneCell();
470 if ($n) {
7192cdc5 471 $page->kill("$prenom $nom est déjà membre du groupe !");
c9110c6c 472 return;
fdf0200a 473 }
474 elseif (Env::has('accept'))
475 {
08cce2ff 476 XDB::execute("INSERT INTO groupex.membres
d501656a 477 VALUES ({?}, {?}, 'membre', 'X', NULL, NULL, NULL, NULL, NULL)",
fdf0200a 478 $globals->asso('id'), $uid);
479 require_once 'diogenes/diogenes.hermes.inc.php';
480 $mailer = new HermesMailer();
481 $mailer->addTo("$u@polytechnique.org");
cab08090 482 $mailer->setFrom('"'.S::v('prenom').' '.S::v('nom')
483 .'" <'.S::v('forlife').'@polytechnique.org>');
fdf0200a 484 $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription');
485 $message = "Cher Camarade,\n"
486 . "\n"
ef7c8560 487 . " Suite à ta demande d'adhésion à ".$globals->asso('nom').",\n"
488 . "j'ai le plaisir de t'annoncer que ton inscription a été validée !\n"
fdf0200a 489 . "\n"
490 . "Bien cordialement,\n"
491 . "{$_SESSION["prenom"]} {$_SESSION["nom"]}.";
492 $mailer->setTxtBody($message);
493 $mailer->send();
ef7c8560 494 $page->kill("$prenom $nom a bien été inscrit");
fdf0200a 495 }
496 elseif (Env::has('refuse'))
497 {
498 require_once 'diogenes/diogenes.hermes.inc.php';
499 $mailer = new HermesMailer();
500 $mailer->addTo("$u@polytechnique.org");
cab08090 501 $mailer->setFrom('"'.S::v('prenom').' '.S::v('nom')
502 .'" <'.S::v('forlife').'@polytechnique.org>');
ef7c8560 503 $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée');
5e2307dc 504 $mailer->setTxtBody(Env::v('motif'));
fdf0200a 505 $mailer->send();
ef7c8560 506 $page->kill("la demande $prenom $nom a bien été refusée");
fdf0200a 507 } else {
508 $page->assign('show_form', true);
509 $page->assign('prenom', $prenom);
510 $page->assign('nom', $nom);
511 $page->assign('promo', $promo);
512 $page->assign('uid', $uid);
513 }
514 return;
515 }
516 return PL_NOT_FOUND;
517 }
518
519 if (is_member()) {
ef7c8560 520 $page->kill("tu es déjà membre !");
fdf0200a 521 return;
522 }
523
524 if (Post::has('inscrire')) {
08cce2ff 525 $res = XDB::query('SELECT IF(m.email IS NULL,
fdf0200a 526 CONCAT(al.alias,"@polytechnique.org"),
527 m.email)
528 FROM groupex.membres AS m
529 INNER JOIN aliases AS al ON (al.type = "a_vie"
530 AND al.id = m.uid)
531 WHERE perms="admin" AND m.asso_id = {?}',
532 $globals->asso('id'));
533 $emails = $res->fetchColumn();
534 $to = implode(',', $emails);
535
536 $append = "\n"
537 . "-- \n"
ef7c8560 538 . "Ce message a été envoyé suite à la demande d'inscription de\n"
cab08090 539 . S::v('prenom').' '.S::v('nom').' (X'.S::v('promo').")\n"
fdf0200a 540 . "Via le site www.polytechnique.net. Tu peux choisir de valider ou\n"
541 . "de refuser sa demande d'inscription depuis la page :\n"
542 .
543 "http://www.polytechnique.net/".$globals->asso("diminutif")."/subscribe/"
cab08090 544 .S::v('forlife')."\n"
fdf0200a 545 . "\n"
ef7c8560 546 . "En cas de problème, contacter l'équipe de Polytechnique.org\n"
547 . "à l'adresse : support@polytechnique.org\n";
fdf0200a 548
549 if (!$to) {
550 $to = $globals->asso("mail").", support@polytechnique.org";
551 $append = "\n-- \nLe groupe ".$globals->asso("nom")
ef7c8560 552 ." n'a pas d'administrateur, l'équipe de"
553 ." Polytechnique.org a été prévenue et va rapidement"
554 ." résoudre ce problème.\n";
fdf0200a 555 }
556
557 require_once 'diogenes/diogenes.hermes.inc.php';
558 $mailer = new HermesMailer();
559 $mailer->addTo($to);
cab08090 560 $mailer->setFrom('"'.S::v('prenom').' '.S::v('nom')
561 .'" <'.S::v('forlife').'@polytechnique.org>');
fdf0200a 562 $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription');
5e2307dc 563 $mailer->setTxtBody(Post::v('message').$append);
fdf0200a 564 $mailer->send();
565 }
566 }
567
4e310c61 568 function handler_admin_annuaire(&$page)
569 {
570 global $globals;
571
4e310c61 572 require_once 'xnet/mail.inc.php';
573
574 new_groupadmin_page('xnet/groupe/annuaire-admin.tpl');
9bb8bf21 575 $mmlist = new MMList(S::v('uid'), S::v('password'),
576 $globals->asso('mail_domain'));
577 $lists = $mmlist->get_lists();
4e310c61 578 if (!$lists) $lists = array();
579 $listes = array_map(create_function('$arr', 'return $arr["list"];'), $lists);
580
581 $subscribers = array();
582
583 foreach ($listes as $list) {
9bb8bf21 584 list(,$members) = $mmlist->get_members($list);
4e310c61 585 $mails = array_map(create_function('$arr', 'return $arr[1];'), $members);
586 $subscribers = array_unique(array_merge($subscribers, $mails));
587 }
588
589 $not_in_group_x = array();
590 $not_in_group_ext = array();
591
592 foreach ($subscribers as $mail) {
08cce2ff 593 $res = XDB::query(
4e310c61 594 'SELECT COUNT(*)
595 FROM groupex.membres AS m
596 LEFT JOIN auth_user_md5 AS u ON (m.uid=u.user_id AND m.uid<50000)
597 LEFT JOIN aliases AS a ON (a.id=u.user_id and a.type="a_vie")
598 WHERE asso_id = {?} AND
599 (m.email = {?} OR CONCAT(a.alias, "@polytechnique.org") = {?})',
600 $globals->asso('id'), $mail, $mail);
601 if ($res->fetchOneCell() == 0) {
602 if (strstr($mail, '@polytechnique.org') === false) {
603 $not_in_group_ext[] = $mail;
604 } else {
605 $not_in_group_x[] = $mail;
606 }
607 }
608 }
609
610 $page->assign('not_in_group_ext', $not_in_group_ext);
611 $page->assign('not_in_group_x', $not_in_group_x);
612 $page->assign('lists', $lists);
613 }
ef7c8560 614
615 function handler_admin_member_new(&$page, $email = null)
616 {
617 global $globals;
618
619 new_groupadmin_page('xnet/groupe/membres-add.tpl');
dc2073c3 620 $page->addJsLink('ajax.js');
ef7c8560 621
622 if (is_null($email)) {
623 return;
624 }
625
626 list(,$fqdn) = explode('@', $email);
627 $fqdn = strtolower($fqdn);
628 $x = ($fqdn == 'polytechnique.org' || $fqdn == 'melix.org' ||
629 $fqdn == 'm4x.org' || $fqdn == 'melix.net');
630
631 if ($x) {
632 require_once 'user.func.inc.php';
633 if ($forlife = get_user_forlife($email)) {
08cce2ff 634 XDB::execute(
ef7c8560 635 'INSERT INTO groupex.membres (uid,asso_id,origine)
ed21e24a 636 SELECT user_id,{?},"X"
637 FROM auth_user_md5 AS u
638 INNER JOIN aliases AS a ON (u.user_id = a.id)
639 WHERE a.alias={?}', $globals->asso('id'), $forlife);
8b00e0e0 640 pl_redirect("member/$email");
ef7c8560 641 } else {
642 $page->trig($email." n'est pas un alias polytechnique.org valide");
643 }
644 } else {
645 if (isvalid_email($email)) {
dc2073c3 646 if (Env::v('x') && Env::has('userid') && Env::i('userid')) {
647 $uid = Env::i('userid');
648 $res = XDB::query("SELECT *
649 FROM auth_user_md5
650 WHERE user_id = {?} AND perms = 'pending'", $uid);
651 if ($res->numRows() == 1) {
652 XDB::execute('INSERT INTO groupex.membres (uid, asso_id, origine, email)
653 VALUES ({?}, {?}, "X", {?})',
654 $uid, $globals->asso('id'), $email);
655 if (Env::v('market')) {
656 $res = XDB::query('SELECT COUNT(*)
657 FROM register_marketing
658 WHERE uid={?} AND email={?}', $uid, $email);
659 if (!$res->fetchOneCell()) {
660 XDB::execute("INSERT INTO register_marketing (uid,sender,email,date,last,nb,type,hash)
661 VALUES ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')",
662 $uid, S::v('uid'), $email, Env::v('market_from'));
663 require_once('validations.inc.php');
664 $req = new MarkReq(S::v('uid'), $uid, $email, Env::v('market_from') == 'user');
665 $req->submit();
666 }
667 }
668 pl_redirect("member/$email");
669 }
670 $page->trig("Utilisateur invalide");
671 } else {
672 $res = XDB::query('SELECT MAX(uid)+1 FROM groupex.membres');
673 $uid = max(intval($res->fetchOneCell()), 50001);
674 XDB::execute('INSERT INTO groupex.membres (uid,asso_id,origine,email)
675 VALUES({?},{?},"ext",{?})', $uid,
676 $globals->asso('id'), $email);
677 pl_redirect("member/$email");
678 }
ef7c8560 679 } else {
680 $page->trig("« <strong>$email</strong> » n'est pas une adresse mail valide");
681 }
682 }
683 }
684
dc2073c3 685 function handler_admin_member_new_ajax(&$page)
686 {
2aa20e30 687 header('Content-Type: text/html; charset="iso-8859-15"');
dc2073c3 688 $page->changeTpl('xnet/groupe/membres-new-search.tpl', NO_SKIN);
689 list($nom, $prenom) = str_replace(array('-', ' ', "'"), '%', array(Env::v('nom'), Env::v('prenom')));
690 $where = "perms = 'pending'";
691 if (!empty($nom)) {
692 $where .= " AND nom LIKE '%$nom%'";
693 }
694 if (!empty($prenom)) {
695 $where .= " AND prenom LIKE '%$prenom%'";
696 }
7cdecf88 697 if (preg_match('/^[0-9]{4}$/', Env::v('promo'))) {
dc2073c3 698 $where .= " AND promo = " . Env::i('promo');
7cdecf88 699 } elseif (Env::has('promo')) {
700 return;
dc2073c3 701 }
702 $res = XDB::iterator("SELECT user_id, nom, prenom, promo
703 FROM auth_user_md5
704 WHERE $where");
705 if ($res->total() < 30) {
706 $page->assign("choix", $res);
707 }
708 }
709
ef7c8560 710 function handler_admin_member_del(&$page, $user = null)
711 {
712 global $globals;
713
714 new_groupadmin_page('xnet/groupe/membres-del.tpl');
715 $user = get_infos($user);
716 if (empty($user)) {
717 return PL_NOT_FOUND;
718 }
719 $page->assign('user', $user);
720
721 if (!Post::has('confirm')) {
722 return;
723 }
724
08cce2ff 725 XDB::execute(
ef7c8560 726 "DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}",
727 $user['uid'], $globals->asso('id'));
728
729 // don't unsubscribe email from list if other user use same email
730 $user_same_email = get_infos($user['email']);
731
732 if (($domain = $globals->asso('mail_domain')) && empty($user_same_email)) {
733
9bb8bf21 734 $mmlist = new MMList(S::v('uid'), S::v('password'), $domain);
735 $listes = $mmlist->get_lists($user['email2']);
ef7c8560 736
737 foreach ($listes as $liste) {
738 if ($liste['sub'] == 2) {
9bb8bf21 739 $mmlist->mass_unsubscribe($liste['list'], Array($user['email2']));
ef7c8560 740 $page->trig("{$user['prenom']} {$user['nom']} a été"
741 ." désinscrit de {$liste['list']}");
742 } elseif ($liste['sub']) {
743 $page->trig("{$user['prenom']} {$user['nom']} a une"
744 ." demande d'inscription en cours sur la"
745 ." liste {$liste['list']}@ !");
746 }
747 }
748
08cce2ff 749 XDB::execute(
ef7c8560 750 "DELETE FROM virtual_redirect
751 USING virtual_redirect
752 INNER JOIN virtual USING(vid)
753 WHERE redirect={?} AND alias LIKE {?}", $user['email'], '%@'.$domain);
754 if (mysql_affected_rows()) {
755 $page->trig("{$user['prenom']} {$user['nom']} a été désabonné des alias du groupe !");
756 }
757 }
758
759 $page->trig("{$user['prenom']} {$user['nom']} a été retiré du groupe !");
760 }
761
762 function handler_admin_member(&$page, $user)
763 {
764 global $globals;
765
766 new_groupadmin_page('xnet/groupe/membres-edit.tpl');
767
768 $user = get_infos($user);
769 if (empty($user)) {
770 return PL_NOT_FOUND;
771 }
772
9bb8bf21 773 $mmlist = new MMList(S::v('uid'), S::v('password'),
774 $globals->asso('mail_domain'));
ef7c8560 775
776 if (Post::has('change')) {
cf5e8ef1 777 $email_changed = ($user['origine'] != 'X' && strtolower($user['email']) != strtolower(Post::v('email')));
c4d57bd8 778 $from_email = $user['email'];
ef7c8560 779 if ($user['origine'] != 'X') {
08cce2ff 780 XDB::query('UPDATE groupex.membres
0cc4c07d 781 SET prenom={?}, nom={?}, email={?}, sexe={?}
782 WHERE uid={?} AND asso_id={?}',
783 Post::v('prenom'), Post::v('nom'),
784 Post::v('email'), Post::v('sexe'),
785 $user['uid'], $globals->asso('id'));
5e2307dc 786 $user['nom'] = Post::v('nom');
787 $user['prenom'] = Post::v('prenom');
0cc4c07d 788 $user['sexe'] = Post::v('sexe');
5e2307dc 789 $user['email'] = Post::v('email');
790 $user['email2'] = Post::v('email');
ef7c8560 791 }
792
5e2307dc 793 $perms = Post::i('is_admin');
ef7c8560 794 if ($user['perms'] != $perms) {
08cce2ff 795 XDB::query('UPDATE groupex.membres SET perms={?}
0cc4c07d 796 WHERE uid={?} AND asso_id={?}',
797 $perms ? 'admin' : 'membre',
798 $user['uid'], $globals->asso('id'));
ef7c8560 799 $user['perms'] = $perms;
800 $page->trig('permissions modifiées');
801 }
802
5e2307dc 803 foreach (Env::v('ml1', array()) as $ml => $state) {
ef7c8560 804 $ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2;
c4d57bd8 805 if ($ask == $state) {
806 if ($state) {
807 $mmlist->replace_email($ml, $from_email, $user['email2']);
808 $page->trig("L'abonnement de {$user['prenom']} {$user['nom']} à $ml@ a été mis à jour");
809 }
810 continue;
811 }
ef7c8560 812 if ($state == '1') {
813 $page->trig("{$user['prenom']} {$user['nom']} a "
814 ."actuellement une demande d'inscription en "
815 ."cours sur <strong>$ml@</strong> !!!");
816 } elseif ($ask) {
9bb8bf21 817 $mmlist->mass_subscribe($ml, Array($user['email2']));
ef7c8560 818 $page->trig("{$user['prenom']} {$user['nom']} a été abonné à $ml@");
819 } else {
c4d57bd8 820 if ($email_changed) {
821 $mmlist->mass_unsubscribe($ml, Array($from_email));
822 } else {
823 $mmlist->mass_unsubscribe($ml, Array($user['email2']));
824 }
ef7c8560 825 $page->trig("{$user['prenom']} {$user['nom']} a été désabonné de $ml@");
826 }
827 }
828
5e2307dc 829 foreach (Env::v('ml3', array()) as $ml => $state) {
ef7c8560 830 $ask = !empty($_REQUEST['ml4'][$ml]);
831 if($state == $ask) continue;
832 if($ask) {
08cce2ff 833 XDB::query("INSERT INTO virtual_redirect (vid,redirect)
dc2073c3 834 SELECT vid,{?} FROM virtual WHERE alias={?}",
835 $user['email'], $ml);
ef7c8560 836 $page->trig("{$user['prenom']} {$user['nom']} a été abonné à $ml");
837 } else {
08cce2ff 838 XDB::query("DELETE FROM virtual_redirect
dc2073c3 839 USING virtual_redirect
840 INNER JOIN virtual USING(vid)
841 WHERE redirect={?} AND alias={?}",
842 $user['email'], $ml);
ef7c8560 843 $page->trig("{$user['prenom']} {$user['nom']} a été désabonné de $ml");
844 }
845 }
846 }
847
848 $page->assign('user', $user);
9bb8bf21 849 $listes = $mmlist->get_lists($user['email2']);
ef7c8560 850 $page->assign('listes', $listes);
851
08cce2ff 852 $res = XDB::query(
ef7c8560 853 'SELECT alias, redirect IS NOT NULL as sub
854 FROM virtual AS v
855 LEFT JOIN virtual_redirect AS vr ON(v.vid=vr.vid AND redirect={?})
856 WHERE alias LIKE {?} AND type="user"',
857 $user['email'], '%@'.$globals->asso('mail_domain'));
858 $page->assign('alias', $res->fetchAllAssoc());
859 }
24bcf50c 860
861 function handler_rss(&$page, $user = null, $hash = null)
862 {
863 global $globals;
864 require_once('rss.inc.php');
865 require_once('url_catcher.inc.php');
866 $uid = init_rss('xnet/groupe/announce-rss.tpl', $user, $hash, false);
867 $page->register_modifier('url_catcher', 'url_catcher');
868
869 if ($uid) {
870 $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.contacts, a.create_date,
871 IF(u2.nom_usage != '', u2.nom_usage, u2.nom) AS nom, u2.prenom, u2.promo
872 FROM auth_user_md5 AS u
873 INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
874 AND (a.promo_max = 0 OR a.promo_max <= u.promo))
875 INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
98a7e9dc 876 WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}",
877 $uid, $globals->asso('id'));
24bcf50c 878 } else {
879 $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.create_date,
880 IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo
881 FROM groupex.announces AS a
882 INNER JOIN auth_user_md5 AS u USING(user_id)
98a7e9dc 883 WHERE FIND_IN_SET(a.flags, 'public') AND peremption >= NOW() AND a.asso_id = {?}",
884 $globals->asso('id'));
24bcf50c 885 }
886 $page->assign('asso', $globals->asso());
887 $page->assign('rss', $rss);
888 }
889
890 function handler_edit_announce(&$page, $aid = null)
891 {
892 global $globals, $platal;
893 new_groupadmin_page('xnet/groupe/announce-edit.tpl');
894 $page->assign('new', is_null($aid));
895 $art = array();
896
897 if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer') {
898 if (!is_null($aid)) {
899 $art['id'] = $aid;
900 }
901 $art['titre'] = Post::v('titre');
902 $art['texte'] = Post::v('texte');
903 $art['contacts'] = Post::v('contacts');
904 $art['promo_min'] = Post::i('promo_min');
905 $art['promo_max'] = Post::i('promo_max');
906 $art['nom'] = S::v('nom');
907 $art['prenom'] = S::v('prenom');
908 $art['promo'] = S::v('promo');
909 $art['forlife'] = S::v('forlife');
910 $art['peremption'] = Post::v('peremption');
911 $art['public'] = Post::has('public');
912 $art['xorg'] = Post::has('xorg');
913 $art['nl'] = Post::has('nl');
914 $art['event'] = Post::v('event');
915
916 $art['contact_html'] = $art['contacts'];
b9a1ba64 917 if ($art['event']) {
918 $art['contact_html'] .= "\n{$globals->baseurl}/{$platal->ns}events/sub/{$art['event']}";
24bcf50c 919 }
2a557a09 920
921 if (!$art['public'] &&
922 ($art['promo_min'] > $art['promo_max'] ||
923 ($art['promo_min'] != 0 && ($art['promo_min'] <= 1900 || $art['promo_min'] >= 2020)) ||
924 ($art['promo_max'] != 0 && ($art['promo_max'] <= 1900 || $art['promo_max'] >= 2020))))
925 {
926 $page->trig("L'intervalle de promotions est invalide");
927 Post::kill('valid');
928 }
24bcf50c 929 }
930
931 if (Post::v('valid') == 'Enregistrer') {
2a557a09 932 $promo_min = ($art['public'] ? 0 : $art['promo_min']);
933 $promo_max = ($art['public'] ? 0 : $art['promo_max']);
24bcf50c 934 if (is_null($aid)) {
935 XDB::query("INSERT INTO groupex.announces
936 (user_id, asso_id, create_date, titre, texte, contacts,
937 peremption, promo_min, promo_max, flags)
938 VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})",
939 S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'],
2a557a09 940 $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : '');
8b83a166 941 $aid = XDB::insertId();
24bcf50c 942 if ($art['xorg']) {
943 require_once('validations.inc.php');
944 require_once('url_catcher.inc.php');
2a557a09 945 $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'],
b9a1ba64 946 url_catcher($art['texte'] . (!empty($art['contact_html']) ? "\n\nContacts :\n" . $art['contact_html'] : "")),
24bcf50c 947 $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid'));
948 $article->submit();
949 $page->trig("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation");
950 }
951 if ($art['nl']) {
952 require_once('validations.inc.php');
2a557a09 953 $article = new NLReq(S::v('uid'), $globals->asso('nom') . " : " .$art['titre'],
954 $art['texte'], $art['contact_html']);
24bcf50c 955 $article->submit();
956 $page->trig("La parution dans la Lettre Mensuelle est en attente de validation");
957 }
958 } else {
959 XDB::query("UPDATE groupex.announces
960 SET titre={?}, texte={?}, contacts={?}, peremption={?},
961 promo_min={?}, promo_max={?}, flags={?}
962 WHERE id={?} AND asso_id={?}",
963 $art['titre'], $art['texte'], $art['contacts'], $art['peremption'],
2a557a09 964 $promo_min, $promo_max, $art['public'] ? 'public' : '',
24bcf50c 965 $art['id'], $globals->asso('id'));
966 }
2a557a09 967 }
968 if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') {
24bcf50c 969 pl_redirect("");
970 }
971
972 if (empty($art) && !is_null($aid)) {
973 $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife,
974 FIND_IN_SET(a.flags, 'public') AS public
975 FROM groupex.announces AS a
976 INNER JOIN auth_user_md5 AS u USING(user_id)
977 INNER JOIN aliases AS l ON (l.id = u.user_id AND l.type = 'a_vie')
978 WHERE asso_id = {?} AND a.id = {?}",
979 $globals->asso('id'), $aid);
980 if ($res->numRows()) {
981 $art = $res->fetchOneAssoc();
982 $art['contact_html'] = $art['contacts'];
983 } else {
984 $page->kill("Aucun article correspond à l'identifiant indiqué");
985 }
986 }
987
988 $select = '';
989 for ($i = 1 ; $i < 30 ; $i++) {
990 $time = time() + 3600 * 24 * $i;
991 $p_stamp = date('Ymd', $time);
992 $year = date('Y', $time);
993 $month = date('m', $time);
994 $day = date('d', $time);
995
996 $select .= "<option value=\"$p_stamp\"";
997 if ($p_stamp == strtr(@$art['peremption'], array("-" => ""))) {
998 $select .= " selected='selected'";
999 }
1000 $select .= "> $day / $month / $year</option>\n";
1001 }
1002 $page->assign('select', $select);
1003
1004 if (is_null($aid)) {
1005 $events = XDB::iterator("SELECT *
1006 FROM groupex.evenements
1007 WHERE asso_id = {?} AND archive = 0",
1008 $globals->asso('id'));
1009 if ($events->total()) {
1010 $page->assign('events', $events);
1011 }
1012 }
1013
1014 require_once('url_catcher.inc.php');
1015 $art['contact_html'] = url_catcher($art['contact_html']);
1016 $page->assign('art', $art);
1017 }
1018
1019 function handler_admin_announce(&$page)
1020 {
1021 global $globals;
1022 new_groupadmin_page('xnet/groupe/announce-admin.tpl');
1023
1024 if (Env::has('del')) {
1025 XDB::execute("DELETE FROM groupex.announces
1026 WHERE id = {?} AND asso_id = {?}",
1027 Env::i('del'), $globals->asso('id'));
1028 }
1029 $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime
1030 FROM groupex.announces AS a
1031 WHERE a.asso_id = {?}
1032 ORDER BY a.peremption DESC",
1033 $globals->asso('id'));
1034 $page->assign('articles', $res);
1035 }
ae7bb180 1036}
1037
1038?>