| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2009 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 | |
| 22 | function get_infos($email) |
| 23 | { |
| 24 | global $globals; |
| 25 | // look for uid instead of email if numeric |
| 26 | $field = is_numeric($email) ? 'uid' : 'email'; |
| 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 | |
| 36 | $res = XDB::query( |
| 37 | "SELECT uid, nom, prenom, email, email AS email2, perms='admin', origine, comm, sexe |
| 38 | FROM #groupex#.membres |
| 39 | WHERE $field = {?} AND asso_id = {?}", $email, $globals->asso('id')); |
| 40 | |
| 41 | if ($res->numRows()) { |
| 42 | $user = $res->fetchOneAssoc(); |
| 43 | if ($user['origine'] == 'X') { |
| 44 | $res = XDB::query("SELECT nom, prenom, promo, FIND_IN_SET('femme', flags) AS sexe |
| 45 | FROM auth_user_md5 |
| 46 | WHERE user_id = {?}", $user['uid']); |
| 47 | $user = array_merge($user, $res->fetchOneAssoc()); |
| 48 | } |
| 49 | return $user; |
| 50 | } elseif ($dom == 'polytechnique.org' || $dom == 'm4x.org') { |
| 51 | $res = XDB::query( |
| 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, |
| 57 | m.perms = 'admin' AS perms, m.origine, m.comm, |
| 58 | FIND_IN_SET('femme', u.flags) AS sexe |
| 59 | FROM #x4dat#.auth_user_md5 AS u |
| 60 | INNER JOIN #x4dat#.aliases AS a ON ( u.user_id = a.id AND a.type != 'homonyme' ) |
| 61 | INNER JOIN #x4dat#.aliases AS b ON ( u.user_id = b.id AND b.type = 'a_vie' ) |
| 62 | LEFT 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 | |
| 71 | class XnetGrpModule extends PLModule |
| 72 | { |
| 73 | function handlers() |
| 74 | { |
| 75 | return array( |
| 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/site' => $this->make_hook('site', AUTH_PUBLIC), |
| 80 | '%grp/edit' => $this->make_hook('edit', AUTH_MDP, 'groupadmin'), |
| 81 | '%grp/mail' => $this->make_hook('mail', AUTH_MDP, 'groupadmin'), |
| 82 | '%grp/forum' => $this->make_hook('forum', AUTH_MDP, 'groupmember'), |
| 83 | '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP, 'groupannu'), |
| 84 | '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP, 'groupmember:groupannu'), |
| 85 | '%grp/annuaire/csv' => $this->make_hook('csv', AUTH_MDP, 'groupmember:groupannu'), |
| 86 | '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP, 'groupannu'), |
| 87 | '%grp/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'groupannu'), |
| 88 | '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP), |
| 89 | '%grp/subscribe/valid' => $this->make_hook('subscribe_valid', AUTH_MDP, 'groupadmin'), |
| 90 | '%grp/unsubscribe' => $this->make_hook('unsubscribe', AUTH_MDP, 'groupmember'), |
| 91 | |
| 92 | '%grp/change_rights' => $this->make_hook('change_rights', AUTH_MDP), |
| 93 | '%grp/admin/annuaire' => $this->make_hook('admin_annuaire', AUTH_MDP, 'groupadmin'), |
| 94 | '%grp/member' => $this->make_hook('admin_member', AUTH_MDP, 'groupadmin'), |
| 95 | '%grp/member/new' => $this->make_hook('admin_member_new', AUTH_MDP, 'groupadmin'), |
| 96 | '%grp/member/new/ajax' => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH), |
| 97 | '%grp/member/del' => $this->make_hook('admin_member_del', AUTH_MDP, 'groupadmin'), |
| 98 | |
| 99 | '%grp/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), |
| 100 | '%grp/announce/new' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'), |
| 101 | '%grp/announce/edit' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'), |
| 102 | '%grp/announce/photo' => $this->make_hook('photo_announce', AUTH_PUBLIC), |
| 103 | '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_MDP, 'groupadmin'), |
| 104 | ); |
| 105 | } |
| 106 | |
| 107 | function handler_index(&$page, $arg = null) |
| 108 | { |
| 109 | global $globals, $platal; |
| 110 | |
| 111 | if (!is_null($arg)) { |
| 112 | return PL_NOT_FOUND; |
| 113 | } |
| 114 | $page->changeTpl('xnetgrp/asso.tpl'); |
| 115 | |
| 116 | if (S::logged()) { |
| 117 | if (Env::has('read')) { |
| 118 | XDB::query('DELETE #groupex#.r.* |
| 119 | FROM #groupex#.announces_read AS r |
| 120 | INNER JOIN #groupex#.announces AS a ON a.id = r.announce_id |
| 121 | WHERE peremption < CURRENT_DATE()'); |
| 122 | XDB::query('INSERT INTO #groupex#.announces_read |
| 123 | VALUES ({?}, {?})', |
| 124 | Env::i('read'), S::i('uid')); |
| 125 | pl_redirect(""); |
| 126 | } |
| 127 | if (Env::has('unread')) { |
| 128 | XDB::query('DELETE FROM #groupex#.announces_read |
| 129 | WHERE announce_id={?} AND user_id={?}', |
| 130 | Env::i('unread'), S::i('uid')); |
| 131 | pl_redirect("#art" . Env::i('unread')); |
| 132 | } |
| 133 | $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo, u.hruid, |
| 134 | FIND_IN_SET('photo', a.flags) AS photo |
| 135 | FROM #groupex#.announces AS a |
| 136 | INNER JOIN #x4dat#.auth_user_md5 AS u USING(user_id) |
| 137 | LEFT JOIN #groupex#.announces_read AS r ON (r.user_id = {?} AND r.announce_id = a.id) |
| 138 | WHERE asso_id = {?} AND peremption >= CURRENT_DATE() |
| 139 | AND (promo_min = 0 OR promo_min <= {?}) |
| 140 | AND (promo_max = 0 OR promo_max >= {?}) |
| 141 | AND r.announce_id IS NULL |
| 142 | ORDER BY a.peremption", |
| 143 | S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo')); |
| 144 | $index = XDB::iterator("SELECT a.id, a.titre, r.user_id IS NULL AS nonlu |
| 145 | FROM #groupex#.announces AS a |
| 146 | LEFT JOIN #groupex#.announces_read AS r ON (a.id = r.announce_id AND r.user_id = {?}) |
| 147 | WHERE asso_id = {?} AND peremption >= CURRENT_DATE() |
| 148 | AND (promo_min = 0 OR promo_min <= {?}) |
| 149 | AND (promo_max = 0 OR promo_max >= {?}) |
| 150 | ORDER BY a.peremption", |
| 151 | S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo')); |
| 152 | $page->assign('article_index', $index); |
| 153 | } else { |
| 154 | $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo, FIND_IN_SET('photo', a.flags) AS photo |
| 155 | FROM #groupex#.announces AS a |
| 156 | INNER JOIN #x4dat#.auth_user_md5 AS u USING(user_id) |
| 157 | WHERE asso_id = {?} AND peremption >= CURRENT_DATE() |
| 158 | AND FIND_IN_SET('public', u.flags)", |
| 159 | $globals->asso('id')); |
| 160 | } |
| 161 | if (may_update()) { |
| 162 | $subs_valid = XDB::query("SELECT uid |
| 163 | FROM #groupex#.membres_sub_requests |
| 164 | WHERE asso_id = {?}", |
| 165 | $globals->asso('id')); |
| 166 | $page->assign('requests', $subs_valid->numRows()); |
| 167 | } |
| 168 | |
| 169 | if (!S::has('core_rss_hash')) { |
| 170 | $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News publiques", |
| 171 | $platal->ns . "rss/rss.xml"); |
| 172 | } else { |
| 173 | $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News", |
| 174 | $platal->ns . 'rss/'.S::v('hruid') .'/'.S::v('core_rss_hash').'/rss.xml'); |
| 175 | } |
| 176 | |
| 177 | $page->assign('articles', $arts); |
| 178 | } |
| 179 | |
| 180 | function handler_logo(&$page) |
| 181 | { |
| 182 | global $globals; |
| 183 | |
| 184 | $res = XDB::query("SELECT logo, logo_mime |
| 185 | FROM #groupex#.asso WHERE id = {?}", |
| 186 | $globals->asso('id')); |
| 187 | list($logo, $logo_mime) = $res->fetchOneRow(); |
| 188 | |
| 189 | pl_cached_dynamic_content_headers(empty($logo) ? "image/jpeg" : $logo_mime); |
| 190 | if (!empty($logo)) { |
| 191 | echo $logo; |
| 192 | } else { |
| 193 | readfile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg'); |
| 194 | } |
| 195 | exit; |
| 196 | } |
| 197 | |
| 198 | function handler_site(&$page) |
| 199 | { |
| 200 | global $globals; |
| 201 | $site = $globals->asso('site'); |
| 202 | if (!$site) { |
| 203 | $page->trigError('Le groupe n\'a pas de site web.'); |
| 204 | return $this->handler_index($page); |
| 205 | } |
| 206 | http_redirect($site); |
| 207 | exit; |
| 208 | } |
| 209 | |
| 210 | function handler_edit(&$page) |
| 211 | { |
| 212 | global $globals; |
| 213 | $page->changeTpl('xnetgrp/edit.tpl'); |
| 214 | |
| 215 | if (Post::has('submit')) { |
| 216 | S::assert_xsrf_token(); |
| 217 | |
| 218 | $flags = new PlFlagSet(); |
| 219 | if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) { |
| 220 | $flags->addFlag('notif_unsub'); |
| 221 | } |
| 222 | $site = trim(Post::v('site')); |
| 223 | if ($site && ($site != "http://")) { |
| 224 | $scheme = parse_url($site, PHP_URL_SCHEME); |
| 225 | if (!$scheme) { |
| 226 | $site = "http://" . $site; |
| 227 | } |
| 228 | } else { |
| 229 | $site = ""; |
| 230 | } |
| 231 | if (S::admin()) { |
| 232 | if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) { |
| 233 | $page->trigError('Le domaine doit être un FQDN (aucune modification effectuée) !!!'); |
| 234 | return; |
| 235 | } |
| 236 | XDB::execute( |
| 237 | "UPDATE #groupex#.asso |
| 238 | SET nom={?}, diminutif={?}, cat={?}, dom={?}, |
| 239 | descr={?}, site={?}, mail={?}, resp={?}, |
| 240 | forum={?}, mail_domain={?}, ax={?}, pub={?}, |
| 241 | sub_url={?}, inscriptible={?}, unsub_url={?}, |
| 242 | flags={?} |
| 243 | WHERE id={?}", |
| 244 | Post::v('nom'), Post::v('diminutif'), |
| 245 | Post::v('cat'), Post::i('dom'), |
| 246 | Post::v('descr'), $site, |
| 247 | Post::v('mail'), Post::v('resp'), |
| 248 | Post::v('forum'), Post::v('mail_domain'), |
| 249 | Post::has('ax'), Post::v('pub'), |
| 250 | Post::v('sub_url'), Post::v('inscriptible'), |
| 251 | Post::v('unsub_url'), $flags, $globals->asso('id')); |
| 252 | if (Post::v('mail_domain')) { |
| 253 | XDB::execute('INSERT IGNORE INTO virtual_domains (domain) VALUES({?})', |
| 254 | Post::v('mail_domain')); |
| 255 | } |
| 256 | } else { |
| 257 | XDB::execute( |
| 258 | "UPDATE #groupex#.asso |
| 259 | SET descr={?}, site={?}, mail={?}, resp={?}, |
| 260 | forum={?}, pub= {?}, sub_url={?}, |
| 261 | unsub_url={?},flags={?} |
| 262 | WHERE id={?}", |
| 263 | Post::v('descr'), $site, |
| 264 | Post::v('mail'), Post::v('resp'), |
| 265 | Post::v('forum'), Post::v('pub'), |
| 266 | Post::v('sub_url'), Post::v('unsub_url'), |
| 267 | $flags, $globals->asso('id')); |
| 268 | } |
| 269 | |
| 270 | if ($_FILES['logo']['name']) { |
| 271 | $logo = file_get_contents($_FILES['logo']['tmp_name']); |
| 272 | $mime = $_FILES['logo']['type']; |
| 273 | XDB::execute('UPDATE #groupex#.asso |
| 274 | SET logo={?}, logo_mime={?} |
| 275 | WHERE id={?}', $logo, $mime, |
| 276 | $globals->asso('id')); |
| 277 | } |
| 278 | |
| 279 | pl_redirect('../'.Post::v('diminutif', $globals->asso('diminutif')).'/edit'); |
| 280 | } |
| 281 | |
| 282 | if (S::admin()) { |
| 283 | $dom = XDB::iterator('SELECT * FROM #groupex#.dom ORDER BY nom'); |
| 284 | $page->assign('dom', $dom); |
| 285 | $page->assign('super', true); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | function handler_mail(&$page) |
| 290 | { |
| 291 | global $globals; |
| 292 | |
| 293 | $page->changeTpl('xnetgrp/mail.tpl'); |
| 294 | $mmlist = new MMList(S::v('uid'), S::v('password'), |
| 295 | $globals->asso('mail_domain')); |
| 296 | $page->assign('listes', $mmlist->get_lists()); |
| 297 | $page->assign('user', S::user()); |
| 298 | $page->addJsLink('ajax.js'); |
| 299 | |
| 300 | if (Post::has('send')) { |
| 301 | S::assert_xsrf_token(); |
| 302 | $from = Post::v('from'); |
| 303 | $sujet = Post::v('sujet'); |
| 304 | $body = Post::v('body'); |
| 305 | |
| 306 | $mls = array_keys(Env::v('ml', array())); |
| 307 | $mbr = array_keys(Env::v('membres', array())); |
| 308 | |
| 309 | $this->load('mail.inc.php'); |
| 310 | set_time_limit(120); |
| 311 | $tos = get_all_redirects($mbr, $mls, $mmlist); |
| 312 | |
| 313 | $upload = PlUpload::get($_FILES['uploaded'], S::user()->login(), 'xnet.emails', true); |
| 314 | if (!$upload && @$_FILES['uploaded']['name'] && PlUpload::$lastError != null) { |
| 315 | $page->trigError(PlUpload::$lastError); |
| 316 | return; |
| 317 | } |
| 318 | |
| 319 | send_xnet_mails($from, $sujet, $body, Env::v('wiki'), $tos, Post::v('replyto'), $upload, @$_FILES['uploaded']['name']); |
| 320 | if ($upload) { |
| 321 | $upload->rm(); |
| 322 | } |
| 323 | $page->killSuccess("Email envoyé !"); |
| 324 | $page->assign('sent', true); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | function handler_forum(&$page, $group = null, $artid = null) |
| 329 | { |
| 330 | global $globals; |
| 331 | $page->changeTpl('xnetgrp/forum.tpl'); |
| 332 | if (!$globals->asso('forum')) { |
| 333 | return PL_NOT_FOUND; |
| 334 | } |
| 335 | require_once 'banana/forum.inc.php'; |
| 336 | $get = array(); |
| 337 | get_banana_params($get, $globals->asso('forum'), $group, $artid); |
| 338 | run_banana($page, 'ForumsBanana', $get); |
| 339 | } |
| 340 | |
| 341 | function handler_annuaire(&$page, $action = null, $subaction = null) |
| 342 | { |
| 343 | global $globals; |
| 344 | |
| 345 | if ($action == 'search') { |
| 346 | http_redirect("https://www.polytechnique.org/search/adv?rechercher=Chercher&groupex={$globals->asso('id')}" |
| 347 | . "&cityid=" . Env::v('cityid') . "&mapid=" . Env::v('mapid')); |
| 348 | } else if ($action == 'geoloc' || $action == 'trombi') { |
| 349 | $view = new UserSet(); |
| 350 | $view->addMod('trombi', 'Trombinoscope'); |
| 351 | $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'annuaire/search')); |
| 352 | $view->apply('annuaire', $page, $action, $subaction); |
| 353 | if ($action == 'geoloc' && $subaction) { |
| 354 | return; |
| 355 | } |
| 356 | } |
| 357 | $page->changeTpl('xnetgrp/annuaire.tpl'); |
| 358 | |
| 359 | $sort = Env::v('order'); |
| 360 | switch (Env::v('order')) { |
| 361 | case 'promo' : $group = 'promo'; $tri = 'promo_o DESC, nom, prenom'; break; |
| 362 | case 'promo_inv': $group = 'promo'; $tri = 'promo_o, nom, prenom'; break; |
| 363 | case 'alpha_inv': $group = 'initiale'; $tri = 'nom DESC, prenom DESC, promo'; break; |
| 364 | default : $group = 'initiale'; $tri = 'nom, prenom, promo'; $sort = 'alpha'; |
| 365 | } |
| 366 | $page->assign('sort', $sort); |
| 367 | |
| 368 | if ($group == 'initiale') { |
| 369 | $res = XDB::iterRow( |
| 370 | 'SELECT UPPER(SUBSTRING( |
| 371 | IF(m.origine="X", IF(u.nom_usage<>"", u.nom_usage, u.nom),m.nom), |
| 372 | 1, 1)) as letter, COUNT(*) |
| 373 | FROM #groupex#.membres AS m |
| 374 | LEFT JOIN #x4dat#.auth_user_md5 AS u ON ( u.user_id = m.uid) |
| 375 | WHERE asso_id = {?} and (u.perms != \'pending\' OR m.email IS NOT NULL) |
| 376 | GROUP BY letter |
| 377 | ORDER BY letter', $globals->asso('id')); |
| 378 | } else { |
| 379 | $res = XDB::iterRow( |
| 380 | 'SELECT IF(m.origine="X",u.promo, |
| 381 | IF(m.origine="ext", "extérieur", "personne morale")) AS promo, |
| 382 | COUNT(*), IF(m.origine="X",u.promo,"") AS promo_o |
| 383 | FROM #groupex#.membres AS m |
| 384 | LEFT JOIN #x4dat#.auth_user_md5 AS u ON ( u.user_id = m.uid ) |
| 385 | WHERE asso_id = {?} |
| 386 | GROUP BY promo |
| 387 | ORDER BY promo_o DESC', $globals->asso('id')); |
| 388 | } |
| 389 | $alphabet = array(); |
| 390 | $nb_tot = 0; |
| 391 | while (list($char, $nb) = $res->next()) { |
| 392 | $alphabet[] = $char; |
| 393 | $nb_tot += $nb; |
| 394 | if (Env::has($group) && $char == mb_strtoupper(Env::v($group))) { |
| 395 | $tot = $nb; |
| 396 | } |
| 397 | } |
| 398 | $page->assign('group', $group); |
| 399 | $page->assign('request_group', Env::v($group)); |
| 400 | $page->assign('only_admin', Env::has('admin')); |
| 401 | $page->assign('alphabet', $alphabet); |
| 402 | $page->assign('nb_tot', $nb_tot); |
| 403 | |
| 404 | $ofs = Env::i('offset'); |
| 405 | $tot = Env::v($group) ? $tot : $nb_tot; |
| 406 | $nbp = intval(($tot-1)/NB_PER_PAGE); |
| 407 | $links = array(); |
| 408 | if ($ofs) { |
| 409 | $links['précédent'] = $ofs-1; |
| 410 | } |
| 411 | for ($i = 0; $i <= $nbp; $i++) { |
| 412 | $links[(string)($i+1)] = $i; |
| 413 | } |
| 414 | if ($ofs < $nbp) { |
| 415 | $links['suivant'] = $ofs+1; |
| 416 | } |
| 417 | if (count($links)>1) { |
| 418 | $page->assign('links', $links); |
| 419 | } |
| 420 | |
| 421 | $ini = ''; |
| 422 | if (Env::has('initiale')) { |
| 423 | $ini = 'AND IF(m.origine="X", |
| 424 | IF(u.nom_usage<>"", u.nom_usage, u.nom), |
| 425 | m.nom) LIKE "'.addslashes(Env::v('initiale')).'%"'; |
| 426 | } elseif (Env::has('promo')) { |
| 427 | $ini = 'AND IF(m.origine="X", u.promo, IF(m.origine="ext", "extérieur", "personne morale")) = "' |
| 428 | .addslashes(Env::v('promo')).'"'; |
| 429 | } elseif (Env::has('admin')) { |
| 430 | $ini = 'AND m.perms = "admin"'; |
| 431 | } |
| 432 | |
| 433 | $ann = XDB::iterator( |
| 434 | "SELECT IF(m.origine='X',IF(u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom, |
| 435 | IF(m.origine='X',u.prenom,m.prenom) AS prenom, |
| 436 | IF(m.origine='X', u.promo, IF(m.origine='ext', 'extérieur', 'personne morale')) AS promo, |
| 437 | IF(m.origine='X',u.promo,'') AS promo_o, |
| 438 | IF(m.origine='X' AND u.perms != 'pending',a.alias,m.email) AS email, |
| 439 | IF(m.origine='X',FIND_IN_SET('femme', u.flags), m.sexe) AS femme, |
| 440 | m.perms='admin' AS admin, |
| 441 | m.origine='X' AS x, |
| 442 | u.perms!='pending' AS inscrit, |
| 443 | m.comm as comm, |
| 444 | m.uid, IF(e.email IS NULL AND FIND_IN_SET('googleapps', u.mail_storage) = 0, NULL, 1) AS actif |
| 445 | FROM #groupex#.membres AS m |
| 446 | LEFT JOIN #x4dat#.auth_user_md5 AS u ON ( u.user_id = m.uid ) |
| 447 | LEFT JOIN #x4dat#.aliases AS a ON ( a.id = m.uid AND a.type='a_vie' ) |
| 448 | LEFT JOIN #x4dat#.emails AS e ON ( e.flags = 'active' AND e.uid = m.uid) |
| 449 | WHERE m.asso_id = {?} $ini |
| 450 | AND (m.origine != 'X' OR u.perms != 'pending' OR m.email IS NOT NULL) |
| 451 | GROUP BY m.uid |
| 452 | ORDER BY $tri |
| 453 | LIMIT {?},{?}", $globals->asso('id'), $ofs*NB_PER_PAGE, NB_PER_PAGE); |
| 454 | $page->assign('ann', $ann); |
| 455 | $page->jsonAssign('ann', $ann); |
| 456 | } |
| 457 | |
| 458 | function handler_trombi(&$page) |
| 459 | { |
| 460 | pl_redirect('annuaire/trombi'); |
| 461 | } |
| 462 | |
| 463 | function handler_geoloc(&$page) |
| 464 | { |
| 465 | pl_redirect('annuaire/geoloc'); |
| 466 | } |
| 467 | |
| 468 | function handler_vcard(&$page, $photos = null) |
| 469 | { |
| 470 | global $globals; |
| 471 | $res = XDB::query('SELECT uid |
| 472 | FROM #groupex#.membres |
| 473 | WHERE asso_id = {?}', $globals->asso('id')); |
| 474 | $vcard = new VCard($photos == 'photos', 'Membre du groupe ' . $globals->asso('nom')); |
| 475 | $vcard->addUsers($res->fetchColumn()); |
| 476 | $vcard->show(); |
| 477 | } |
| 478 | |
| 479 | function handler_csv(&$page, $filename = null) |
| 480 | { |
| 481 | global $globals; |
| 482 | if (is_null($filename)) { |
| 483 | $filename = $globals->asso('diminutif') . '.csv'; |
| 484 | } |
| 485 | $ann = XDB::iterator( |
| 486 | "SELECT IF(m.origine='X',IF(u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom, |
| 487 | IF(m.origine='X',u.prenom,m.prenom) AS prenom, |
| 488 | IF(m.origine='X', u.promo, IF(m.origine='ext', 'extérieur', 'personne morale')) AS promo, |
| 489 | IF(m.origine='X' AND u.perms != 'pending',CONCAT(a.alias, '@', {?}), m.email) AS email, |
| 490 | IF(m.origine='X',FIND_IN_SET('femme', u.flags), m.sexe) AS femme, |
| 491 | m.comm as comm |
| 492 | FROM #groupex#.membres AS m |
| 493 | LEFT JOIN #x4dat#.auth_user_md5 AS u ON ( u.user_id = m.uid ) |
| 494 | LEFT JOIN #x4dat#.aliases AS a ON ( a.id = m.uid AND a.type = 'a_vie' ) |
| 495 | WHERE m.asso_id = {?} |
| 496 | AND (m.origine != 'X' OR u.perms != 'pending' OR m.email IS NOT NULL) |
| 497 | GROUP BY m.uid |
| 498 | ORDER BY nom, prenom", |
| 499 | $globals->mail->domain, $globals->asso('id')); |
| 500 | pl_content_headers("text/x-csv"); |
| 501 | $page->changeTpl('xnetgrp/annuaire-csv.tpl', NO_SKIN); |
| 502 | $page->assign('ann', $ann); |
| 503 | } |
| 504 | |
| 505 | private function removeSubscriptionRequest($uid) |
| 506 | { |
| 507 | global $globals; |
| 508 | XDB::execute("DELETE FROM #groupex#.membres_sub_requests |
| 509 | WHERE asso_id = {?} AND uid = {?}", |
| 510 | $globals->asso('id'), $uid); |
| 511 | } |
| 512 | |
| 513 | private function validSubscription(User &$user) |
| 514 | { |
| 515 | global $globals; |
| 516 | $this->removeSubscriptionRequest($user->id()); |
| 517 | XDB::execute("INSERT IGNORE INTO #groupex#.membres (asso_id, uid) |
| 518 | VALUES ({?}, {?})", |
| 519 | $globals->asso('id'), $user->id()); |
| 520 | if (XDB::affectedRows() == 1) { |
| 521 | $mailer = new PlMailer(); |
| 522 | $mailer->addTo($user->forlifeEmail()); |
| 523 | $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>'); |
| 524 | $mailer->setSubject('[' . $globals->asso('nom') . '] Demande d\'inscription'); |
| 525 | $message = ($user->isFemale() ? 'Chère' : 'Cher') . " Camarade,\n" |
| 526 | . "\n" |
| 527 | . " Suite à ta demande d'adhésion à " . $globals->asso('nom') . ",\n" |
| 528 | . "j'ai le plaisir de t'annoncer que ton inscription a été validée !\n" |
| 529 | . "\n" |
| 530 | . "Bien cordialement,\n" |
| 531 | . "-- \n" |
| 532 | . S::user()->fullName() . '.'; |
| 533 | $mailer->setTxtBody($message); |
| 534 | $mailer->send(); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | function handler_subscribe(&$page, $u = null) |
| 539 | { |
| 540 | global $globals; |
| 541 | $page->changeTpl('xnetgrp/inscrire.tpl'); |
| 542 | |
| 543 | if (!$globals->asso('inscriptible')) |
| 544 | $page->kill("Il n'est pas possible de s'inscire en ligne à ce " |
| 545 | ."groupe. Essaie de joindre le contact indiqué " |
| 546 | ."sur la page de présentation."); |
| 547 | |
| 548 | if (!is_null($u) && may_update()) { |
| 549 | $user = User::get($u); |
| 550 | if (!$user) { |
| 551 | return PL_NOT_FOUND; |
| 552 | } else { |
| 553 | $page->assign('user', $user); |
| 554 | } |
| 555 | |
| 556 | // Retrieves the subscription status, and the reason. |
| 557 | $res = XDB::query("SELECT reason |
| 558 | FROM #groupex#.membres_sub_requests |
| 559 | WHERE asso_id = {?} AND uid = {?}", |
| 560 | $globals->asso('id'), $user->id()); |
| 561 | $reason = ($res->numRows() ? $res->fetchOneCell() : null); |
| 562 | |
| 563 | $res = XDB::query("SELECT COUNT(*) |
| 564 | FROM #groupex#.membres |
| 565 | WHERE asso_id = {?} AND uid = {?}", |
| 566 | $globals->asso('id'), $user->id()); |
| 567 | $already_member = ($res->fetchOneCell() > 0); |
| 568 | |
| 569 | // Handles the membership request. |
| 570 | if ($already_member) { |
| 571 | $this->removeSubscriptionRequest($user->id()); |
| 572 | $page->kill($user->fullName() . ' est déjà membre du groupe !'); |
| 573 | } elseif (Env::has('accept')) { |
| 574 | S::assert_xsrf_token(); |
| 575 | |
| 576 | $this->validSubscription($user); |
| 577 | pl_redirect("member/" . $user->login()); |
| 578 | } elseif (Env::has('refuse')) { |
| 579 | S::assert_xsrf_token(); |
| 580 | |
| 581 | $this->removeSubscriptionRequest($user->id()); |
| 582 | $mailer = new PlMailer(); |
| 583 | $mailer->addTo($user->forlifeEmail()); |
| 584 | $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>'); |
| 585 | $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée'); |
| 586 | $mailer->setTxtBody(Env::v('motif')); |
| 587 | $mailer->send(); |
| 588 | $page->killSuccess("La demande de {$user->fullName()} a bien été refusée."); |
| 589 | } else { |
| 590 | $page->assign('show_form', true); |
| 591 | $page->assign('reason', $reason); |
| 592 | } |
| 593 | return; |
| 594 | } |
| 595 | |
| 596 | if (is_member()) { |
| 597 | $page->kill("Tu es déjà membre !"); |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | $res = XDB::query("SELECT uid |
| 602 | FROM #groupex#.membres_sub_requests |
| 603 | WHERE uid = {?} AND asso_id = {?}", |
| 604 | S::i('uid'), $globals->asso('id')); |
| 605 | if ($res->numRows() != 0) { |
| 606 | $page->kill("Tu as déjà demandé ton inscription à ce groupe. Cette demande est actuellement en attente de validation."); |
| 607 | return; |
| 608 | } |
| 609 | |
| 610 | if (Post::has('inscrire')) { |
| 611 | S::assert_xsrf_token(); |
| 612 | |
| 613 | XDB::execute("INSERT INTO #groupex#.membres_sub_requests (asso_id, uid, ts, reason) |
| 614 | VALUES ({?}, {?}, NOW(), {?})", |
| 615 | $globals->asso('id'), S::i('uid'), Post::v('message')); |
| 616 | $res = XDB::query('SELECT IF(m.email IS NULL, |
| 617 | CONCAT(al.alias,"@polytechnique.org"), |
| 618 | m.email) |
| 619 | FROM #groupex#.membres AS m |
| 620 | INNER JOIN #x4dat#.aliases AS al ON (al.type = "a_vie" |
| 621 | AND al.id = m.uid) |
| 622 | WHERE perms="admin" AND m.asso_id = {?}', |
| 623 | $globals->asso('id')); |
| 624 | $emails = $res->fetchColumn(); |
| 625 | $to = implode(',', $emails); |
| 626 | |
| 627 | $append = "\n" |
| 628 | . "-- \n" |
| 629 | . "Ce message a été envoyé suite à la demande d'inscription de\n" |
| 630 | . S::user()->fullName() . ' (X' . S::v('promo') . ")\n" |
| 631 | . "Via le site www.polytechnique.net. Tu peux choisir de valider ou\n" |
| 632 | . "de refuser sa demande d'inscription depuis la page :\n" |
| 633 | . "http://www.polytechnique.net/" . $globals->asso("diminutif") . "/subscribe/" . S::user()->login() . "\n" |
| 634 | . "\n" |
| 635 | . "En cas de problème, contacter l'équipe de Polytechnique.org\n" |
| 636 | . "à l'adresse : support@polytechnique.org\n"; |
| 637 | |
| 638 | if (!$to) { |
| 639 | $to = ($globals->asso('mail') != '') ? $globals->asso('mail') . ', ' : ''; |
| 640 | $to .= 'support@polytechnique.org'; |
| 641 | $append = "\n-- \nLe groupe ".$globals->asso("nom") |
| 642 | ." n'a pas d'administrateur, l'équipe de" |
| 643 | ." Polytechnique.org a été prévenue et va rapidement" |
| 644 | ." résoudre ce problème.\n"; |
| 645 | } |
| 646 | |
| 647 | $mailer = new PlMailer(); |
| 648 | $mailer->addTo($to); |
| 649 | $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>'); |
| 650 | $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription'); |
| 651 | $mailer->setTxtBody(Post::v('message').$append); |
| 652 | $mailer->send(); |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | function handler_subscribe_valid(&$page) |
| 657 | { |
| 658 | global $globals; |
| 659 | |
| 660 | if (Post::has('valid')) { |
| 661 | S::assert_xsrf_token(); |
| 662 | $subs = Post::v('subs'); |
| 663 | if (is_array($subs)) { |
| 664 | $users = array(); |
| 665 | foreach ($subs as $hruid => $val) { |
| 666 | if ($val == '1') { |
| 667 | $user = User::get($hruid); |
| 668 | if ($user) { |
| 669 | $this->validSubscription($user); |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | $it = XDB::iterator("SELECT IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, |
| 677 | u.prenom, u.promo, u.hruid, s.ts AS date |
| 678 | FROM #groupex#.membres_sub_requests AS s |
| 679 | INNER JOIN #x4dat#.auth_user_md5 AS u ON (s.uid = u.user_id) |
| 680 | WHERE asso_id = {?} |
| 681 | ORDER BY nom, prenom", |
| 682 | $globals->asso('id')); |
| 683 | |
| 684 | $page->changeTpl('xnetgrp/subscribe-valid.tpl'); |
| 685 | $page->assign('valid', $it); |
| 686 | } |
| 687 | |
| 688 | function handler_change_rights(&$page) |
| 689 | { |
| 690 | if (Env::has('right') && (may_update() || S::has('suid'))) { |
| 691 | switch (Env::v('right')) { |
| 692 | case 'admin': |
| 693 | Platal::session()->stopSUID(); |
| 694 | break; |
| 695 | case 'anim': |
| 696 | Platal::session()->doSelfSuid(); |
| 697 | may_update(true); |
| 698 | is_member(true); |
| 699 | break; |
| 700 | case 'member': |
| 701 | Platal::session()->doSelfSuid(); |
| 702 | may_update(false, true); |
| 703 | is_member(true); |
| 704 | break; |
| 705 | case 'logged': |
| 706 | Platal::session()->doSelfSuid(); |
| 707 | may_update(false, true); |
| 708 | is_member(false, true); |
| 709 | break; |
| 710 | } |
| 711 | } |
| 712 | // var_dump($_SESSION); |
| 713 | http_redirect($_SERVER['HTTP_REFERER']); |
| 714 | } |
| 715 | |
| 716 | function handler_admin_annuaire(&$page) |
| 717 | { |
| 718 | global $globals; |
| 719 | |
| 720 | $this->load('mail.inc.php'); |
| 721 | $page->changeTpl('xnetgrp/annuaire-admin.tpl'); |
| 722 | $mmlist = new MMList(S::v('uid'), S::v('password'), |
| 723 | $globals->asso('mail_domain')); |
| 724 | $lists = $mmlist->get_lists(); |
| 725 | if (!$lists) $lists = array(); |
| 726 | $listes = array_map(create_function('$arr', 'return $arr["list"];'), $lists); |
| 727 | |
| 728 | $subscribers = array(); |
| 729 | |
| 730 | foreach ($listes as $list) { |
| 731 | list(,$members) = $mmlist->get_members($list); |
| 732 | $mails = array_map(create_function('$arr', 'return $arr[1];'), $members); |
| 733 | $subscribers = array_unique(array_merge($subscribers, $mails)); |
| 734 | } |
| 735 | |
| 736 | $not_in_group_x = array(); |
| 737 | $not_in_group_ext = array(); |
| 738 | |
| 739 | foreach ($subscribers as $mail) { |
| 740 | $res = XDB::query( |
| 741 | 'SELECT COUNT(*) |
| 742 | FROM #groupex#.membres AS m |
| 743 | LEFT JOIN #x4dat#.auth_user_md5 AS u ON (m.uid = u.user_id AND m.uid < 50000) |
| 744 | LEFT JOIN #x4dat#.aliases AS a ON (a.id = u.user_id and a.type = "a_vie") |
| 745 | WHERE asso_id = {?} AND |
| 746 | (m.email = {?} OR CONCAT(a.alias, "@polytechnique.org") = {?})', |
| 747 | $globals->asso('id'), $mail, $mail); |
| 748 | if ($res->fetchOneCell() == 0) { |
| 749 | if (strstr($mail, '@polytechnique.org') === false) { |
| 750 | $not_in_group_ext[] = $mail; |
| 751 | } else { |
| 752 | $not_in_group_x[] = $mail; |
| 753 | } |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | $page->assign('not_in_group_ext', $not_in_group_ext); |
| 758 | $page->assign('not_in_group_x', $not_in_group_x); |
| 759 | $page->assign('lists', $lists); |
| 760 | } |
| 761 | |
| 762 | function handler_admin_member_new(&$page, $email = null) |
| 763 | { |
| 764 | global $globals; |
| 765 | |
| 766 | $page->changeTpl('xnetgrp/membres-add.tpl'); |
| 767 | $page->addJsLink('ajax.js'); |
| 768 | |
| 769 | if (is_null($email)) { |
| 770 | return; |
| 771 | } else { |
| 772 | S::assert_xsrf_token(); |
| 773 | } |
| 774 | |
| 775 | if (!User::isForeignEmailAddress($email)) { |
| 776 | $user = User::get($email); |
| 777 | if ($user) { |
| 778 | XDB::execute("REPLACE INTO #groupex#.membres (uid, asso_id, origine) |
| 779 | VALUES ({?}, {?}, 'X')", |
| 780 | $user->id(), $globals->asso('id')); |
| 781 | pl_redirect("member/" . $user->login()); |
| 782 | } |
| 783 | } else { |
| 784 | if (isvalid_email($email)) { |
| 785 | if (Env::v('x') && Env::has('userid') && Env::i('userid')) { |
| 786 | $uid = Env::i('userid'); |
| 787 | $res = XDB::query("SELECT * |
| 788 | FROM auth_user_md5 |
| 789 | WHERE user_id = {?} AND perms = 'pending'", $uid); |
| 790 | if ($res->numRows() == 1) { |
| 791 | if (Env::v('market')) { |
| 792 | $market = Marketing::get($uid, $email); |
| 793 | if (!$market) { |
| 794 | $market = new Marketing($uid, $email, 'group', $globals->asso('nom'), |
| 795 | Env::v('market_from'), S::v('uid')); |
| 796 | $market->add(); |
| 797 | } |
| 798 | } |
| 799 | XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id, origine, email) |
| 800 | VALUES ({?}, {?}, "X", {?})', |
| 801 | $uid, $globals->asso('id'), $email); |
| 802 | $this->removeSubscriptionRequest($uid); |
| 803 | pl_redirect("member/$email"); |
| 804 | } |
| 805 | $page->trigError("Utilisateur invalide"); |
| 806 | } else { |
| 807 | $res = XDB::query('SELECT MAX(uid) + 1 FROM #groupex#.membres'); |
| 808 | $uid = max(intval($res->fetchOneCell()), 50001); |
| 809 | XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id, origine, email) |
| 810 | VALUES ({?}, {?}, "ext", {?})', |
| 811 | $uid, $globals->asso('id'), $email); |
| 812 | pl_redirect("member/$email"); |
| 813 | } |
| 814 | } else { |
| 815 | $page->trigError("« <strong>$email</strong> » n'est pas une adresse email valide."); |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | function handler_admin_member_new_ajax(&$page) |
| 821 | { |
| 822 | pl_content_headers("text/html"); |
| 823 | $page->changeTpl('xnetgrp/membres-new-search.tpl', NO_SKIN); |
| 824 | $res = null; |
| 825 | if (Env::has('login')) { |
| 826 | require_once 'user.func.inc.php'; |
| 827 | $res = get_not_registered_user(Env::v('login'), true); |
| 828 | } |
| 829 | if (is_null($res)) { |
| 830 | list($nom, $prenom) = str_replace(array('-', ' ', "'"), '%', array(Env::v('nom'), Env::v('prenom'))); |
| 831 | $where = "perms = 'pending'"; |
| 832 | if (!empty($nom)) { |
| 833 | $where .= " AND nom LIKE '%$nom%'"; |
| 834 | } |
| 835 | if (!empty($prenom)) { |
| 836 | $where .= " AND prenom LIKE '%$prenom%'"; |
| 837 | } |
| 838 | if (preg_match('/^[0-9]{4}$/', Env::v('promo'))) { |
| 839 | $where .= " AND promo = " . Env::i('promo'); |
| 840 | } elseif (preg_match('/^[0-9]{2}$/', Env::v('promo'))) { |
| 841 | $where .= " AND MOD(promo, 100) = " . Env::i('promo'); |
| 842 | } elseif (Env::has('promo')) { |
| 843 | return; |
| 844 | } |
| 845 | $res = XDB::iterator("SELECT user_id, nom, prenom, promo |
| 846 | FROM auth_user_md5 |
| 847 | WHERE $where"); |
| 848 | } |
| 849 | if ($res && $res->total() < 30) { |
| 850 | $page->assign("choix", $res); |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | function unsubscribe(&$user) |
| 855 | { |
| 856 | global $globals; |
| 857 | XDB::execute( |
| 858 | "DELETE FROM #groupex#.membres WHERE uid={?} AND asso_id={?}", |
| 859 | $user['uid'], $globals->asso('id')); |
| 860 | |
| 861 | if ($globals->asso('notif_unsub')) { |
| 862 | $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl'); |
| 863 | $res = XDB::iterRow("SELECT a.alias, u.prenom, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom |
| 864 | FROM #groupex#.membres AS m |
| 865 | INNER JOIN #x4dat#.aliases AS a ON (m.uid = a.id AND FIND_IN_SET('bestalias', a.flags)) |
| 866 | INNER JOIn #x4dat#.auth_user_md5 AS u ON (u.user_id = a.id) |
| 867 | WHERE m.asso_id = {?} AND m.perms = 'admin'", |
| 868 | $globals->asso('id')); |
| 869 | while (list($alias, $prenom, $nom) = $res->next()) { |
| 870 | $mailer->addTo("\"$prenom $nom\" <$alias@{$globals->mail->domain}>"); |
| 871 | } |
| 872 | $mailer->assign('group', $globals->asso('nom')); |
| 873 | $mailer->assign('prenom', $user['prenom']); |
| 874 | $mailer->assign('nom', $user['nom']); |
| 875 | $mailer->assign('mail', $user['email2']); |
| 876 | $mailer->assign('selfdone', $user['uid'] == S::i('uid')); |
| 877 | $mailer->send(); |
| 878 | } |
| 879 | |
| 880 | $user_same_email = get_infos($user['email']); |
| 881 | $domain = $globals->asso('mail_domain'); |
| 882 | |
| 883 | if (!$domain || (!empty($user_same_email) && $user_same_email['uid'] != $user['uid'])) { |
| 884 | return true; |
| 885 | } |
| 886 | |
| 887 | $mmlist = new MMList(S::v('uid'), S::v('password'), $domain); |
| 888 | $listes = $mmlist->get_lists($user['email2']); |
| 889 | |
| 890 | $may_update = may_update(); |
| 891 | $warning = false; |
| 892 | foreach ($listes as $liste) { |
| 893 | if ($liste['sub'] == 2) { |
| 894 | if ($may_update) { |
| 895 | $mmlist->mass_unsubscribe($liste['list'], Array($user['email2'])); |
| 896 | } else { |
| 897 | $mmlist->unsubscribe($liste['list']); |
| 898 | } |
| 899 | } elseif ($liste['sub']) { |
| 900 | Platal::page()->trigWarning("{$user['prenom']} {$user['nom']} a une" |
| 901 | ." demande d'inscription en cours sur la" |
| 902 | ." liste {$liste['list']}@ !"); |
| 903 | $warning = true; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | XDB::execute( |
| 908 | "DELETE FROM virtual_redirect |
| 909 | USING virtual_redirect |
| 910 | INNER JOIN virtual USING(vid) |
| 911 | WHERE redirect={?} AND alias LIKE {?}", $user['email'], '%@'.$domain); |
| 912 | return !$warning; |
| 913 | } |
| 914 | |
| 915 | function handler_unsubscribe(&$page) |
| 916 | { |
| 917 | $page->changeTpl('xnetgrp/membres-del.tpl'); |
| 918 | $user = get_infos(S::user()->id()); |
| 919 | if (empty($user)) { |
| 920 | return PL_NOT_FOUND; |
| 921 | } |
| 922 | $page->assign('self', true); |
| 923 | $page->assign('user', $user); |
| 924 | |
| 925 | if (!Post::has('confirm')) { |
| 926 | return; |
| 927 | } else { |
| 928 | S::assert_xsrf_token(); |
| 929 | } |
| 930 | |
| 931 | if ($this->unsubscribe($user)) { |
| 932 | $page->trigSuccess('Vous avez été désinscrit du groupe avec succès.'); |
| 933 | } else { |
| 934 | $page->trigWarning('Vous avez été désinscrit du groupe, mais des erreurs se sont produites lors des désinscriptions des alias et des listes de diffusion.'); |
| 935 | } |
| 936 | $page->assign('is_member', is_member(true)); |
| 937 | } |
| 938 | |
| 939 | function handler_admin_member_del(&$page, $user = null) |
| 940 | { |
| 941 | $page->changeTpl('xnetgrp/membres-del.tpl'); |
| 942 | $user = get_infos($user); |
| 943 | if (empty($user)) { |
| 944 | return PL_NOT_FOUND; |
| 945 | } |
| 946 | $page->assign('user', $user); |
| 947 | |
| 948 | if (!Post::has('confirm')) { |
| 949 | return; |
| 950 | } else { |
| 951 | S::assert_xsrf_token(); |
| 952 | } |
| 953 | |
| 954 | if ($this->unsubscribe($user)) { |
| 955 | $page->trigSuccess("{$user['prenom']} {$user['nom']} a été désabonné du groupe !"); |
| 956 | } else { |
| 957 | $page->trigWarning("{$user['prenom']} {$user['nom']} a été désabonné du groupe, mais des erreurs subsistent !"); |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | private function changeLogin(PlPage &$page, array &$user, MMList &$mmlist, $login) |
| 962 | { |
| 963 | require_once 'user.func.inc.php'; |
| 964 | // Search the uid of the user... |
| 965 | $res = XDB::query("SELECT f.id, f.alias |
| 966 | FROM aliases AS a |
| 967 | INNER JOIN aliases AS f ON (f.id = a.id AND f.type = 'a_vie') |
| 968 | WHERE a.alias = {?}", |
| 969 | $login); |
| 970 | if ($res->numRows() == 0) { |
| 971 | $x = get_not_registered_user($login); |
| 972 | if (!$x) { |
| 973 | $page->trigError("Le login $login ne correspond à aucun X."); |
| 974 | return false; |
| 975 | } else if (count($x) > 1) { |
| 976 | $page->trigError("Le login $login correspond a plusieurs camarades."); |
| 977 | return false; |
| 978 | } |
| 979 | $uid = $x[0]['user_id']; |
| 980 | $sub = false; |
| 981 | } else { |
| 982 | list($uid, $login) = $res->fetchOneRow(); |
| 983 | $sub = true; |
| 984 | } |
| 985 | |
| 986 | // Check if the user is already in the group |
| 987 | global $globals; |
| 988 | $res = XDB::query("SELECT uid, email |
| 989 | FROM #groupex#.membres |
| 990 | WHERE uid = {?} AND asso_id = {?}", |
| 991 | $uid, $globals->asso('id')); |
| 992 | if ($res->numRows()) { |
| 993 | list($uid, $email) = $res->fetchOneRow(); |
| 994 | XDB::execute("DELETE FROM #groupex#.membres |
| 995 | WHERE uid = {?}", |
| 996 | $user['uid']); |
| 997 | } else { |
| 998 | $email = $user['email']; |
| 999 | XDB::execute("UPDATE #groupex#.membres |
| 1000 | SET uid = {?}, origine = 'X' |
| 1001 | WHERE uid = {?} AND asso_id = {?}", |
| 1002 | $uid, $user['uid'], $globals->asso('id')); |
| 1003 | } |
| 1004 | if ($sub) { |
| 1005 | $email = $login . '@' . $globals->mail->domain; |
| 1006 | } |
| 1007 | |
| 1008 | // Update subscription to aliases |
| 1009 | if ($email != $user['email']) { |
| 1010 | XDB::execute("UPDATE IGNORE virtual_redirect AS vr |
| 1011 | INNER JOIN virtual AS v ON(vr.vid = v.vid AND SUBSTRING_INDEX(alias, '@', -1) = {?}) |
| 1012 | SET vr.redirect = {?} |
| 1013 | WHERE vr.redirect = {?}", |
| 1014 | $globals->asso('mail_domain'), $email, $user['email']); |
| 1015 | XDB::execute("DELETE vr.* |
| 1016 | FROM virtual_redirect AS vr |
| 1017 | INNER JOIN virtual AS v ON(vr.vid = v.vid AND SUBSTRING_INDEX(alias, '@', -1) = {?}) |
| 1018 | WHERE vr.redirect = {?}", |
| 1019 | $globals->asso('mail_domain'), $user['email']); |
| 1020 | foreach (Env::v('ml1', array()) as $ml => $state) { |
| 1021 | $mmlist->replace_email($ml, $user['email'], $email); |
| 1022 | } |
| 1023 | } |
| 1024 | if ($sub) { |
| 1025 | return $login; |
| 1026 | } |
| 1027 | return $user['email']; |
| 1028 | } |
| 1029 | |
| 1030 | function handler_admin_member(&$page, $user) |
| 1031 | { |
| 1032 | global $globals; |
| 1033 | |
| 1034 | $page->changeTpl('xnetgrp/membres-edit.tpl'); |
| 1035 | |
| 1036 | $user = get_infos($user); |
| 1037 | if (empty($user)) { |
| 1038 | return PL_NOT_FOUND; |
| 1039 | } |
| 1040 | |
| 1041 | $mmlist = new MMList(S::v('uid'), S::v('password'), |
| 1042 | $globals->asso('mail_domain')); |
| 1043 | |
| 1044 | if (Post::has('change')) { |
| 1045 | S::assert_xsrf_token(); |
| 1046 | |
| 1047 | // Convert user status to X |
| 1048 | if ($user['origine'] == 'ext' && trim(Post::v('login_X'))) { |
| 1049 | $forlife = $this->changeLogin($page, $user, $mmlist, trim(Post::v('login_X'))); |
| 1050 | if ($forlife) { |
| 1051 | pl_redirect('member/' . $forlife); |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | // Update user info |
| 1056 | $email_changed = ($user['origine'] != 'X' && strtolower($user['email']) != strtolower(Post::v('email'))); |
| 1057 | $from_email = $user['email']; |
| 1058 | if ($user['origine'] != 'X') { |
| 1059 | $user['nom'] = Post::v('nom'); |
| 1060 | $user['prenom'] = (Post::v('origine') == 'ext') ? Post::v('prenom') : ''; |
| 1061 | $user['sexe'] = (Post::v('origine') == 'ext') ? Post::v('sexe') : 0; |
| 1062 | $user['origine'] = Post::v('origine'); |
| 1063 | XDB::query('UPDATE #groupex#.membres |
| 1064 | SET prenom = {?}, nom = {?}, email = {?}, sexe = {?}, origine = {?} |
| 1065 | WHERE uid = {?} AND asso_id = {?}', |
| 1066 | $user['prenom'], $user['nom'], Post::v('email'), |
| 1067 | $user['sexe'], $user['origine'], |
| 1068 | $user['uid'], $globals->asso('id')); |
| 1069 | $user['email'] = Post::v('email'); |
| 1070 | $user['email2'] = Post::v('email'); |
| 1071 | $page->trigSuccess('Données de l\'utilisateur mise à jour.'); |
| 1072 | } |
| 1073 | |
| 1074 | $perms = Post::i('is_admin'); |
| 1075 | $comm = trim(Post::s('comm')); |
| 1076 | if ($user['perms'] != $perms || $user['comm'] != $comm) { |
| 1077 | XDB::query('UPDATE #groupex#.membres |
| 1078 | SET perms = {?}, comm = {?} |
| 1079 | WHERE uid = {?} AND asso_id = {?}', |
| 1080 | $perms ? 'admin' : 'membre', $comm, |
| 1081 | $user['uid'], $globals->asso('id')); |
| 1082 | if ($perms != $user['perms']) { |
| 1083 | $page->trigSuccess('Permissions modifiées !'); |
| 1084 | } |
| 1085 | if ($comm != $user['comm']) { |
| 1086 | $page->trigSuccess('Commentaire mis à jour.'); |
| 1087 | } |
| 1088 | $user['perms'] = $perms; |
| 1089 | $user['comm'] = $comm; |
| 1090 | } |
| 1091 | |
| 1092 | // Update ML subscriptions |
| 1093 | foreach (Env::v('ml1', array()) as $ml => $state) { |
| 1094 | $ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2; |
| 1095 | if ($ask == $state) { |
| 1096 | if ($state && $email_changed) { |
| 1097 | $mmlist->replace_email($ml, $from_email, $user['email2']); |
| 1098 | $page->trigSuccess("L'abonnement de {$user['prenom']} {$user['nom']} à $ml@ a été mis à jour."); |
| 1099 | } |
| 1100 | continue; |
| 1101 | } |
| 1102 | if ($state == '1') { |
| 1103 | $page->trigWarning("{$user['prenom']} {$user['nom']} a " |
| 1104 | ."actuellement une demande d'inscription en " |
| 1105 | ."cours sur <strong>$ml@</strong> !!!"); |
| 1106 | } elseif ($ask) { |
| 1107 | $mmlist->mass_subscribe($ml, Array($user['email2'])); |
| 1108 | $page->trigSuccess("{$user['prenom']} {$user['nom']} a été abonné à $ml@."); |
| 1109 | } else { |
| 1110 | if ($email_changed) { |
| 1111 | $mmlist->mass_unsubscribe($ml, Array($from_email)); |
| 1112 | } else { |
| 1113 | $mmlist->mass_unsubscribe($ml, Array($user['email2'])); |
| 1114 | } |
| 1115 | $page->trigSuccess("{$user['prenom']} {$user['nom']} a été désabonné de $ml@."); |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | // Change subscriptioin to aliases |
| 1120 | foreach (Env::v('ml3', array()) as $ml => $state) { |
| 1121 | $ask = !empty($_REQUEST['ml4'][$ml]); |
| 1122 | if($state == $ask) continue; |
| 1123 | if($ask) { |
| 1124 | XDB::query("INSERT INTO virtual_redirect (vid,redirect) |
| 1125 | SELECT vid,{?} FROM virtual WHERE alias={?}", |
| 1126 | $user['email'], $ml); |
| 1127 | $page->trigSuccess("{$user['prenom']} {$user['nom']} a été abonné à $ml."); |
| 1128 | } else { |
| 1129 | XDB::query("DELETE FROM virtual_redirect |
| 1130 | USING virtual_redirect |
| 1131 | INNER JOIN virtual USING(vid) |
| 1132 | WHERE redirect={?} AND alias={?}", |
| 1133 | $user['email'], $ml); |
| 1134 | $page->trigSuccess("{$user['prenom']} {$user['nom']} a été désabonné de $ml."); |
| 1135 | } |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | $page->assign('user', $user); |
| 1140 | $listes = $mmlist->get_lists($user['email2']); |
| 1141 | $page->assign('listes', $listes); |
| 1142 | |
| 1143 | $res = XDB::query( |
| 1144 | 'SELECT alias, redirect IS NOT NULL as sub |
| 1145 | FROM virtual AS v |
| 1146 | LEFT JOIN virtual_redirect AS vr ON(v.vid=vr.vid AND (redirect = {?} OR redirect = {?})) |
| 1147 | WHERE alias LIKE {?} AND type="user"', |
| 1148 | $user['email'], $user['email2'], '%@'.$globals->asso('mail_domain')); |
| 1149 | $page->assign('alias', $res->fetchAllAssoc()); |
| 1150 | } |
| 1151 | |
| 1152 | function handler_rss(&$page, $user = null, $hash = null) |
| 1153 | { |
| 1154 | global $globals; |
| 1155 | $page->assign('asso', $globals->asso()); |
| 1156 | |
| 1157 | $this->load('feed.inc.php'); |
| 1158 | $feed = new XnetGrpEventFeed(); |
| 1159 | return $feed->run($page, $user, $hash, false); |
| 1160 | } |
| 1161 | |
| 1162 | private function upload_image(PlPage &$page, PlUpload &$upload) |
| 1163 | { |
| 1164 | if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) { |
| 1165 | return true; |
| 1166 | } |
| 1167 | if (!$upload->upload($_FILES['image']) && !$upload->download(Env::v('image_url'))) { |
| 1168 | $page->trigError('Impossible de télécharger l\'image'); |
| 1169 | return false; |
| 1170 | } elseif (!$upload->isType('image')) { |
| 1171 | $page->trigError('Le fichier n\'est pas une image valide au format JPEG, GIF ou PNG.'); |
| 1172 | $upload->rm(); |
| 1173 | return false; |
| 1174 | } elseif (!$upload->resizeImage(200, 300, 100, 100, 32284)) { |
| 1175 | $page->trigError('Impossible de retraiter l\'image'); |
| 1176 | return false; |
| 1177 | } |
| 1178 | return true; |
| 1179 | } |
| 1180 | |
| 1181 | function handler_photo_announce(&$page, $eid = null) { |
| 1182 | if ($eid) { |
| 1183 | $res = XDB::query("SELECT * FROM #groupex#.announces_photo WHERE eid = {?}", $eid); |
| 1184 | if ($res->numRows()) { |
| 1185 | $photo = $res->fetchOneAssoc(); |
| 1186 | pl_cached_dynamic_content_headers("image/" . $photo['attachmime']); |
| 1187 | echo $photo['attach']; |
| 1188 | exit; |
| 1189 | } |
| 1190 | } else { |
| 1191 | $upload = new PlUpload(S::user()->login(), 'xnetannounce'); |
| 1192 | if ($upload->exists() && $upload->isType('image')) { |
| 1193 | pl_cached_dynamic_content_headers($upload->contentType()); |
| 1194 | echo $upload->getContents(); |
| 1195 | exit; |
| 1196 | } |
| 1197 | } |
| 1198 | global $globals; |
| 1199 | pl_cached_dynamic_content_headers("image/png"); |
| 1200 | echo file_get_contents($globals->spoolroot . '/htdocs/images/logo.png'); |
| 1201 | exit; |
| 1202 | } |
| 1203 | |
| 1204 | function handler_edit_announce(&$page, $aid = null) |
| 1205 | { |
| 1206 | global $globals, $platal; |
| 1207 | $page->changeTpl('xnetgrp/announce-edit.tpl'); |
| 1208 | $page->assign('new', is_null($aid)); |
| 1209 | $art = array(); |
| 1210 | |
| 1211 | if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer' |
| 1212 | || Post::v('valid') == 'Supprimer l\'image' || Post::v('valid') == 'Pas d\'image') { |
| 1213 | S::assert_xsrf_token(); |
| 1214 | |
| 1215 | if (!is_null($aid)) { |
| 1216 | $art['id'] = $aid; |
| 1217 | } |
| 1218 | $art['titre'] = Post::v('titre'); |
| 1219 | $art['texte'] = Post::v('texte'); |
| 1220 | $art['contacts'] = Post::v('contacts'); |
| 1221 | $art['promo_min'] = Post::i('promo_min'); |
| 1222 | $art['promo_max'] = Post::i('promo_max'); |
| 1223 | $art['nom'] = S::v('nom'); |
| 1224 | $art['prenom'] = S::v('prenom'); |
| 1225 | $art['promo'] = S::v('promo'); |
| 1226 | $art['hruid'] = S::user()->login(); |
| 1227 | $art['peremption'] = Post::v('peremption'); |
| 1228 | $art['public'] = Post::has('public'); |
| 1229 | $art['xorg'] = Post::has('xorg'); |
| 1230 | $art['nl'] = Post::has('nl'); |
| 1231 | $art['event'] = Post::v('event'); |
| 1232 | $upload = new PlUpload(S::user()->login(), 'xnetannounce'); |
| 1233 | $this->upload_image($page, $upload); |
| 1234 | |
| 1235 | $art['contact_html'] = $art['contacts']; |
| 1236 | if ($art['event']) { |
| 1237 | $art['contact_html'] .= "\n{$globals->baseurl}/{$platal->ns}events/sub/{$art['event']}"; |
| 1238 | } |
| 1239 | |
| 1240 | if (!$art['public'] && |
| 1241 | (($art['promo_min'] > $art['promo_max'] && $art['promo_max'] != 0) || |
| 1242 | ($art['promo_min'] != 0 && ($art['promo_min'] <= 1900 || $art['promo_min'] >= 2020)) || |
| 1243 | ($art['promo_max'] != 0 && ($art['promo_max'] <= 1900 || $art['promo_max'] >= 2020)))) |
| 1244 | { |
| 1245 | $page->trigError("L'intervalle de promotions est invalide."); |
| 1246 | Post::kill('valid'); |
| 1247 | } |
| 1248 | |
| 1249 | if (!trim($art['titre']) || !trim($art['texte'])) { |
| 1250 | $page->trigError("L'article doit avoir un titre et un contenu."); |
| 1251 | Post::kill('valid'); |
| 1252 | } |
| 1253 | |
| 1254 | if (Post::v('valid') == 'Supprimer l\'image') { |
| 1255 | $upload->rm(); |
| 1256 | Post::kill('valid'); |
| 1257 | } |
| 1258 | $art['photo'] = $upload->exists() || Post::i('photo'); |
| 1259 | if (Post::v('valid') == 'Pas d\'image' && !is_null($aid)) { |
| 1260 | XDB::query("DELETE FROM #groupex#.announces_photo WHERE eid = {?}", $aid); |
| 1261 | $upload->rm(); |
| 1262 | Post::kill('valid'); |
| 1263 | $art['photo'] = false; |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | if (Post::v('valid') == 'Enregistrer') { |
| 1268 | $promo_min = ($art['public'] ? 0 : $art['promo_min']); |
| 1269 | $promo_max = ($art['public'] ? 0 : $art['promo_max']); |
| 1270 | $flags = new PlFlagSet(); |
| 1271 | if ($art['public']) { |
| 1272 | $flags->addFlag('public'); |
| 1273 | } |
| 1274 | if ($art['photo']) { |
| 1275 | $flags->addFlag('photo'); |
| 1276 | } |
| 1277 | if (is_null($aid)) { |
| 1278 | $fulltext = $art['texte']; |
| 1279 | if (!empty($art['contact_html'])) { |
| 1280 | $fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html']; |
| 1281 | } |
| 1282 | $post = null;/* |
| 1283 | if ($globals->asso('forum')) { |
| 1284 | require_once 'banana/forum.inc.php'; |
| 1285 | $banana = new ForumsBanana(S::user()); |
| 1286 | $post = $banana->post($globals->asso('forum'), null, |
| 1287 | $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80)); |
| 1288 | }*/ |
| 1289 | XDB::query("INSERT INTO #groupex#.announces |
| 1290 | (user_id, asso_id, create_date, titre, texte, contacts, |
| 1291 | peremption, promo_min, promo_max, flags, post_id) |
| 1292 | VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", |
| 1293 | S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'], |
| 1294 | $art['peremption'], $promo_min, $promo_max, $flags, $post); |
| 1295 | $aid = XDB::insertId(); |
| 1296 | if ($art['photo']) { |
| 1297 | list($imgx, $imgy, $imgtype) = $upload->imageInfo(); |
| 1298 | XDB::execute("INSERT INTO #groupex#.announces_photo |
| 1299 | SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", |
| 1300 | $aid, $imgtype, $imgx, $imgy, $upload->getContents()); |
| 1301 | } |
| 1302 | if ($art['xorg']) { |
| 1303 | require_once('validations.inc.php'); |
| 1304 | $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext, |
| 1305 | $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::user(), |
| 1306 | $upload); |
| 1307 | $article->submit(); |
| 1308 | $page->trigWarning("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation."); |
| 1309 | } else if ($upload && $upload->exists()) { |
| 1310 | $upload->rm(); |
| 1311 | } |
| 1312 | if ($art['nl']) { |
| 1313 | require_once('validations.inc.php'); |
| 1314 | $article = new NLReq(S::user(), $globals->asso('nom') . " : " .$art['titre'], |
| 1315 | $art['texte'], $art['contact_html']); |
| 1316 | $article->submit(); |
| 1317 | $page->trigWarning("La parution dans la Lettre Mensuelle est en attente de validation."); |
| 1318 | } |
| 1319 | } else { |
| 1320 | XDB::query("UPDATE #groupex#.announces |
| 1321 | SET titre={?}, texte={?}, contacts={?}, peremption={?}, |
| 1322 | promo_min={?}, promo_max={?}, flags={?} |
| 1323 | WHERE id={?} AND asso_id={?}", |
| 1324 | $art['titre'], $art['texte'], $art['contacts'], $art['peremption'], |
| 1325 | $promo_min, $promo_max, $flags, |
| 1326 | $art['id'], $globals->asso('id')); |
| 1327 | if ($art['photo'] && $upload->exists()) { |
| 1328 | list($imgx, $imgy, $imgtype) = $upload->imageInfo(); |
| 1329 | XDB::execute("REPLACE INTO #groupex#.announces_photo |
| 1330 | SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", |
| 1331 | $aid, $imgtype, $imgx, $imgy, $upload->getContents()); |
| 1332 | $upload->rm(); |
| 1333 | } |
| 1334 | } |
| 1335 | } |
| 1336 | if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') { |
| 1337 | pl_redirect(""); |
| 1338 | } |
| 1339 | |
| 1340 | if (empty($art) && !is_null($aid)) { |
| 1341 | $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, u.hruid, |
| 1342 | FIND_IN_SET('public', a.flags) AS public, |
| 1343 | FIND_IN_SET('photo', a.flags) AS photo |
| 1344 | FROM #groupex#.announces AS a |
| 1345 | INNER JOIN #x4dat#.auth_user_md5 AS u USING(user_id) |
| 1346 | WHERE asso_id = {?} AND a.id = {?}", |
| 1347 | $globals->asso('id'), $aid); |
| 1348 | if ($res->numRows()) { |
| 1349 | $art = $res->fetchOneAssoc(); |
| 1350 | $art['contact_html'] = $art['contacts']; |
| 1351 | } else { |
| 1352 | $page->kill("Aucun article correspond à l'identifiant indiqué."); |
| 1353 | } |
| 1354 | } |
| 1355 | |
| 1356 | if (is_null($aid)) { |
| 1357 | $events = XDB::iterator("SELECT * |
| 1358 | FROM #groupex#.evenements |
| 1359 | WHERE asso_id = {?} AND archive = 0", |
| 1360 | $globals->asso('id')); |
| 1361 | if ($events->total()) { |
| 1362 | $page->assign('events', $events); |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | $art['contact_html'] = @MiniWiki::WikiToHTML($art['contact_html']); |
| 1367 | $page->assign('art', $art); |
| 1368 | $page->assign_by_ref('upload', $upload); |
| 1369 | } |
| 1370 | |
| 1371 | function handler_admin_announce(&$page) |
| 1372 | { |
| 1373 | global $globals; |
| 1374 | $page->changeTpl('xnetgrp/announce-admin.tpl'); |
| 1375 | |
| 1376 | if (Env::has('del')) { |
| 1377 | S::assert_xsrf_token(); |
| 1378 | XDB::execute("DELETE FROM #groupex#.announces |
| 1379 | WHERE id = {?} AND asso_id = {?}", |
| 1380 | Env::i('del'), $globals->asso('id')); |
| 1381 | } |
| 1382 | $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime |
| 1383 | FROM #groupex#.announces AS a |
| 1384 | WHERE a.asso_id = {?} |
| 1385 | ORDER BY a.peremption DESC", |
| 1386 | $globals->asso('id')); |
| 1387 | $page->assign('articles', $res); |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
| 1392 | ?> |