+
+ function handler_admin_member_new(&$page, $email = null)
+ {
+ global $globals;
+
+ $page->changeTpl('xnetgrp/membres-add.tpl');
+ $page->addJsLink('ajax.js');
+
+ if (is_null($email)) {
+ return;
+ }
+
+ if (strpos($email, '@') === false) {
+ $x = true;
+ } else {
+ list(,$fqdn) = explode('@', $email, 2);
+ $fqdn = strtolower($fqdn);
+ $x = ($fqdn == 'polytechnique.org' || $fqdn == 'melix.org' ||
+ $fqdn == 'm4x.org' || $fqdn == 'melix.net');
+ }
+ if ($x) {
+ require_once 'user.func.inc.php';
+ if ($forlife = get_user_forlife($email)) {
+ XDB::execute(
+ 'INSERT INTO groupex.membres (uid,asso_id,origine)
+ SELECT user_id,{?},"X"
+ FROM auth_user_md5 AS u
+ INNER JOIN aliases AS a ON (u.user_id = a.id)
+ WHERE a.alias={?}', $globals->asso('id'), $forlife);
+ pl_redirect("member/$forlife");
+ } else {
+ $page->trigError($email." n'est pas un alias polytechnique.org valide.");
+ }
+ } else {
+ require_once 'xorg.misc.inc.php';
+ if (isvalid_email($email)) {
+ if (Env::v('x') && Env::has('userid') && Env::i('userid')) {
+ $uid = Env::i('userid');
+ $res = XDB::query("SELECT *
+ FROM auth_user_md5
+ WHERE user_id = {?} AND perms = 'pending'", $uid);
+ if ($res->numRows() == 1) {
+ if (Env::v('market')) {
+ $market = Marketing::get($uid, $email);
+ if (!$market) {
+ $market = new Marketing($uid, $email, 'group', $globals->asso('nom'),
+ Env::v('market_from'), S::v('uid'));
+ $market->add();
+ }
+ }
+ XDB::execute('INSERT INTO groupex.membres (uid, asso_id, origine, email)
+ VALUES ({?}, {?}, "X", {?})',
+ $uid, $globals->asso('id'), $email);
+ pl_redirect("member/$email");
+ }
+ $page->trigError("Utilisateur invalide");
+ } else {
+ $res = XDB::query('SELECT MAX(uid)+1 FROM groupex.membres');
+ $uid = max(intval($res->fetchOneCell()), 50001);
+ XDB::execute('INSERT INTO groupex.membres (uid,asso_id,origine,email)
+ VALUES({?},{?},"ext",{?})', $uid,
+ $globals->asso('id'), $email);
+ pl_redirect("member/$email");
+ }
+ } else {
+ $page->trigError("« <strong>$email</strong> » n'est pas une adresse mail valide.");
+ }
+ }
+ }
+
+ function handler_admin_member_new_ajax(&$page)
+ {
+ header('Content-Type: text/html; charset="UTF-8"');
+ $page->changeTpl('xnetgrp/membres-new-search.tpl', NO_SKIN);
+ $res = null;
+ if (Env::has('login')) {
+ require_once 'user.func.inc.php';
+ $res = get_not_registered_user(Env::v('login'), true);
+ }
+ if (is_null($res)) {
+ list($nom, $prenom) = str_replace(array('-', ' ', "'"), '%', array(Env::v('nom'), Env::v('prenom')));
+ $where = "perms = 'pending'";
+ if (!empty($nom)) {
+ $where .= " AND nom LIKE '%$nom%'";
+ }
+ if (!empty($prenom)) {
+ $where .= " AND prenom LIKE '%$prenom%'";
+ }
+ if (preg_match('/^[0-9]{4}$/', Env::v('promo'))) {
+ $where .= " AND promo = " . Env::i('promo');
+ } elseif (preg_match('/^[0-9]{2}$/', Env::v('promo'))) {
+ $where .= " AND MOD(promo, 100) = " . Env::i('promo');
+ } elseif (Env::has('promo')) {
+ return;
+ }
+ $res = XDB::iterator("SELECT user_id, nom, prenom, promo
+ FROM auth_user_md5
+ WHERE $where");
+ }
+ if ($res && $res->total() < 30) {
+ $page->assign("choix", $res);
+ }
+ }
+
+ function unsubscribe(&$user)
+ {
+ global $globals, $page;
+ XDB::execute(
+ "DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}",
+ $user['uid'], $globals->asso('id'));
+
+ if ($globals->asso('notif_unsub')) {
+ $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl');
+ $res = XDB::iterRow("SELECT a.alias, u.prenom, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom
+ FROM groupex.membres AS m
+ INNER JOIN aliases AS a ON (m.uid = a.id AND FIND_IN_SET('bestalias', a.flags))
+ INNER JOIn auth_user_md5 AS u ON (u.user_id = a.id)
+ WHERE m.asso_id = {?} AND m.perms = 'admin'",
+ $globals->asso('id'));
+ while (list($alias, $prenom, $nom) = $res->next()) {
+ $mailer->addTo("\"$prenom $nom\" <$alias@{$globals->mail->domain}>");
+ }
+ $mailer->assign('group', $globals->asso('nom'));
+ $mailer->assign('prenom', $user['prenom']);
+ $mailer->assign('nom', $user['nom']);
+ $mailer->assign('mail', $user['email2']);
+ $mailer->assign('selfdone', $user['uid'] == S::i('uid'));
+ $mailer->send();
+ }
+
+ $user_same_email = get_infos($user['email']);
+ $domain = $globals->asso('mail_domain');
+
+ if (!$domain || (!empty($user_same_email) && $user_same_email['uid'] != $user['uid'])) {
+ return true;
+ }
+
+ $mmlist = new MMList(S::v('uid'), S::v('password'), $domain);
+ $listes = $mmlist->get_lists($user['email2']);
+
+ $may_update = may_update();
+ $warning = false;
+ foreach ($listes as $liste) {
+ if ($liste['sub'] == 2) {
+ if ($may_update) {
+ $mmlist->mass_unsubscribe($liste['list'], Array($user['email2']));
+ } else {
+ $mmlist->unsubscribe($liste['list']);
+ }
+ } elseif ($liste['sub']) {
+ $page->trigWarning("{$user['prenom']} {$user['nom']} a une"
+ ." demande d'inscription en cours sur la"
+ ." liste {$liste['list']}@ !");
+ $warning = true;
+ }
+ }
+
+ XDB::execute(
+ "DELETE FROM virtual_redirect
+ USING virtual_redirect
+ INNER JOIN virtual USING(vid)
+ WHERE redirect={?} AND alias LIKE {?}", $user['email'], '%@'.$domain);
+ return !$warning;
+ }
+
+ function handler_unsubscribe(&$page)
+ {
+ $page->changeTpl('xnetgrp/membres-del.tpl');
+ $user = get_infos(S::v('forlife'));
+ if (empty($user)) {
+ return PL_NOT_FOUND;
+ }
+ $page->assign('self', true);
+ $page->assign('user', $user);
+
+ if (!Post::has('confirm')) {
+ return;
+ }
+
+ if ($this->unsubscribe($user)) {
+ $page->trigSuccess('Vous avez été désinscrit du groupe avec succès.');
+ } else {
+ $page->trigWarning('Vous avez été désinscrit du groupe, mais des erreurs se sont produites lors des désinscriptions des alias et des mailing-lists.');
+ }
+ $page->assign('is_member', is_member(true));
+ }
+
+ function handler_admin_member_del(&$page, $user = null)
+ {
+ $page->changeTpl('xnetgrp/membres-del.tpl');
+ $user = get_infos($user);
+ if (empty($user)) {
+ return PL_NOT_FOUND;
+ }
+ $page->assign('user', $user);
+
+ if (!Post::has('confirm')) {
+ return;
+ }
+
+ if ($this->unsubscribe($user)) {
+ $page->trigSuccess("{$user['prenom']} {$user['nom']} a été désabonné du groupe !");
+ } else {
+ $page->trigWarning("{$user['prenom']} {$user['nom']} a été désabonné du groupe, mais des erreurs subsistent !");
+ }
+ }
+
+ private function changeLogin(PlatalPage &$page, array &$user, MMList &$mmlist, $login)
+ {
+ require_once 'user.func.inc.php';
+ // Search the uid of the user...
+ $res = XDB::query("SELECT f.id, f.alias
+ FROM aliases AS a
+ INNER JOIN aliases AS f ON (f.id = a.id AND f.type = 'a_vie')
+ WHERE a.alias = {?}",
+ $login);
+ if ($res->numRows() == 0) {
+ $x = get_not_registered_user($login);
+ if (!$x) {
+ $page->trigError("Le login $login ne correspond à aucun X.");
+ return false;
+ } else if (count($x) > 1) {
+ $page->trigError("Le login $login correspond a plusieurs camarades.");
+ return false;
+ }
+ $uid = $x[0]['user_id'];
+ $sub = false;
+ } else {
+ list($uid, $login) = $res->fetchOneRow();
+ $sub = true;
+ }
+
+ // Check if the user is already in the group
+ global $globals;
+ $res = XDB::query("SELECT uid, email
+ FROM groupex.membres
+ WHERE uid = {?} AND asso_id = {?}",
+ $uid, $globals->asso('id'));
+ if ($res->numRows()) {
+ list($uid, $email) = $res->fetchOneRow();
+ XDB::execute("DELETE FROM groupex.membres
+ WHERE uid = {?}",
+ $user['uid']);
+ } else {
+ $email = $user['email'];
+ XDB::execute("UPDATE groupex.membres
+ SET uid = {?}, origine = 'X'
+ WHERE uid = {?} AND asso_id = {?}",
+ $uid, $user['uid'], $globals->asso('id'));
+ }
+ if ($sub) {
+ $email = $login . '@' . $globals->mail->domain;
+ }
+
+ // Update subscription to aliases
+ if ($email != $user['email']) {
+ XDB::execute("UPDATE IGNORE virtual_redirect AS vr
+ INNER JOIN virtual AS v ON(vr.vid = v.vid AND SUBSTRING_INDEX(alias, '@', -1) = {?})
+ SET vr.redirect = {?}
+ WHERE vr.redirect = {?}",
+ $globals->asso('mail_domain'), $email, $user['email']);
+ XDB::execute("DELETE vr.*
+ FROM virtual_redirect AS vr
+ INNER JOIN virtual AS v ON(vr.vid = v.vid AND SUBSTRING_INDEX(alias, '@', -1) = {?})
+ WHERE vr.redirect = {?}",
+ $globals->asso('mail_domain'), $user['email']);
+ foreach (Env::v('ml1', array()) as $ml => $state) {
+ $mmlist->replace_email($ml, $user['email'], $email);
+ }
+ }
+ if ($sub) {
+ return $login;
+ }
+ return $user['email'];
+ }
+
+ function handler_admin_member(&$page, $user)
+ {
+ global $globals;
+
+ $page->changeTpl('xnetgrp/membres-edit.tpl');
+
+ $user = get_infos($user);
+ if (empty($user)) {
+ return PL_NOT_FOUND;
+ }
+
+ $mmlist = new MMList(S::v('uid'), S::v('password'),
+ $globals->asso('mail_domain'));
+
+ if (Post::has('change')) {
+ // Convert user status to X
+ if ($user['origine'] == 'ext' && trim(Post::v('login_X'))) {
+ $forlife = $this->changeLogin($page, $user, $mmlist, trim(Post::v('login_X')));
+ if ($forlife) {
+ pl_redirect('member/' . $forlife);
+ }
+ }
+
+ // Update user info
+ $email_changed = ($user['origine'] != 'X' && strtolower($user['email']) != strtolower(Post::v('email')));
+ $from_email = $user['email'];
+ if ($user['origine'] != 'X') {
+ $user['nom'] = Post::v('nom');
+ $user['prenom'] = (Post::v('origine') == 'ext') ? Post::v('prenom') : '';
+ $user['sexe'] = (Post::v('origine') == 'ext') ? Post::v('sexe') : 0;
+ $user['origine'] = Post::v('origine');
+ XDB::query('UPDATE groupex.membres
+ SET prenom={?}, nom={?}, email={?}, sexe={?}, origine={?}
+ WHERE uid={?} AND asso_id={?}',
+ $user['prenom'], $user['nom'], Post::v('email'),
+ $user['sexe'], $user['origine'], $user['uid'],
+ $globals->asso('id'));
+ $user['email'] = Post::v('email');
+ $user['email2'] = Post::v('email');
+ }
+
+ $perms = Post::i('is_admin');
+ if ($user['perms'] != $perms) {
+ XDB::query('UPDATE groupex.membres SET perms={?}
+ WHERE uid={?} AND asso_id={?}',
+ $perms ? 'admin' : 'membre',
+ $user['uid'], $globals->asso('id'));
+ $user['perms'] = $perms;
+ $page->trigSuccess('Permissions modifiées !');
+ }
+
+ // Update ML subscriptions
+ foreach (Env::v('ml1', array()) as $ml => $state) {
+ $ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2;
+ if ($ask == $state) {
+ if ($state && $email_changed) {
+ $mmlist->replace_email($ml, $from_email, $user['email2']);
+ $page->trigSuccess("L'abonnement de {$user['prenom']} {$user['nom']} à $ml@ a été mis à jour.");
+ }
+ continue;
+ }
+ if ($state == '1') {
+ $page->trigWarning("{$user['prenom']} {$user['nom']} a "
+ ."actuellement une demande d'inscription en "
+ ."cours sur <strong>$ml@</strong> !!!");
+ } elseif ($ask) {
+ $mmlist->mass_subscribe($ml, Array($user['email2']));
+ $page->trigSuccess("{$user['prenom']} {$user['nom']} a été abonné à $ml@.");
+ } else {
+ if ($email_changed) {
+ $mmlist->mass_unsubscribe($ml, Array($from_email));
+ } else {
+ $mmlist->mass_unsubscribe($ml, Array($user['email2']));
+ }
+ $page->trigSuccess("{$user['prenom']} {$user['nom']} a été désabonné de $ml@.");
+ }
+ }
+
+ // Change subscriptioin to aliases
+ foreach (Env::v('ml3', array()) as $ml => $state) {
+ $ask = !empty($_REQUEST['ml4'][$ml]);
+ if($state == $ask) continue;
+ if($ask) {
+ XDB::query("INSERT INTO virtual_redirect (vid,redirect)
+ SELECT vid,{?} FROM virtual WHERE alias={?}",
+ $user['email'], $ml);
+ $page->trigSuccess("{$user['prenom']} {$user['nom']} a été abonné à $ml.");
+ } else {
+ XDB::query("DELETE FROM virtual_redirect
+ USING virtual_redirect
+ INNER JOIN virtual USING(vid)
+ WHERE redirect={?} AND alias={?}",
+ $user['email'], $ml);
+ $page->trigSuccess("{$user['prenom']} {$user['nom']} a été désabonné de $ml.");
+ }
+ }
+ }
+
+ $page->assign('user', $user);
+ echo $user['email2'];
+ $listes = $mmlist->get_lists($user['email2']);
+ $page->assign('listes', $listes);
+
+ $res = XDB::query(
+ 'SELECT alias, redirect IS NOT NULL as sub
+ FROM virtual AS v
+ LEFT JOIN virtual_redirect AS vr ON(v.vid=vr.vid AND (redirect = {?} OR redirect = {?}))
+ WHERE alias LIKE {?} AND type="user"',
+ $user['email'], $user['email2'], '%@'.$globals->asso('mail_domain'));
+ $page->assign('alias', $res->fetchAllAssoc());
+ }
+
+ function handler_rss(&$page, $user = null, $hash = null)
+ {
+ global $globals;
+ require_once('rss.inc.php');
+ $uid = init_rss('xnetgrp/announce-rss.tpl', $user, $hash, false);
+
+ if ($uid) {
+ $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.contacts, a.create_date,
+ IF(u2.nom_usage != '', u2.nom_usage, u2.nom) AS nom, u2.prenom, u2.promo,
+ FIND_IN_SET('photo', a.flags) AS photo
+ FROM auth_user_md5 AS u
+ INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
+ AND (a.promo_max = 0 OR a.promo_max <= u.promo))
+ INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
+ WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}",
+ $uid, $globals->asso('id'));
+ } else {
+ $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.create_date,
+ IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo
+ FROM groupex.announces AS a
+ INNER JOIN auth_user_md5 AS u USING(user_id)
+ WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}",
+ $globals->asso('id'));
+ }
+ $page->assign('asso', $globals->asso());
+ $page->assign('rss', $rss);
+ }
+
+ private function upload_image(PlatalPage &$page, PlUpload &$upload)
+ {
+ if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
+ return true;
+ }
+ if (!$upload->upload($_FILES['image']) && !$upload->download(Env::v('image_url'))) {
+ $page->trigError('Impossible de télécharger l\'image');
+ return false;
+ } elseif (!$upload->isType('image')) {
+ $page->trigError('Le fichier n\'est pas une image valide au format JPEG, GIF ou PNG.');
+ $upload->rm();
+ return false;
+ } elseif (!$upload->resizeImage(200, 300, 100, 100, 32284)) {
+ $page->trigError('Impossible de retraiter l\'image');
+ return false;
+ }
+ return true;
+ }
+
+ function handler_photo_announce(&$page, $eid = null) {
+ if ($eid) {
+ $res = XDB::query("SELECT * FROM groupex.announces_photo WHERE eid = {?}", $eid);
+ if ($res->numRows()) {
+ $photo = $res->fetchOneAssoc();
+ header('Content-Type: image/' . $photo['attachmime']);
+ echo $photo['attach'];
+ exit;
+ }
+ } else {
+ $upload = new PlUpload(S::v('forlife'), 'xnetannounce');
+ if ($upload->exists() && $upload->isType('image')) {
+ header('Content-Type: ' . $upload->contentType());
+ echo $upload->getContents();
+ exit;
+ }
+ }
+ global $globals;
+ header('Content-Type: image/png');
+ echo file_get_contents($globals->spoolroot . '/htdocs/images/logo.png');
+ exit;
+ }
+
+ function handler_edit_announce(&$page, $aid = null)
+ {
+ global $globals, $platal;
+ $page->changeTpl('xnetgrp/announce-edit.tpl');
+ $page->assign('new', is_null($aid));
+ $art = array();
+
+ if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer'
+ || Post::v('valid') == 'Supprimer l\'image' || Post::v('valid') == 'Pas d\'image') {
+ if (!is_null($aid)) {
+ $art['id'] = $aid;
+ }
+ $art['titre'] = Post::v('titre');
+ $art['texte'] = Post::v('texte');
+ $art['contacts'] = Post::v('contacts');
+ $art['promo_min'] = Post::i('promo_min');
+ $art['promo_max'] = Post::i('promo_max');
+ $art['nom'] = S::v('nom');
+ $art['prenom'] = S::v('prenom');
+ $art['promo'] = S::v('promo');
+ $art['forlife'] = S::v('forlife');
+ $art['peremption'] = Post::v('peremption');
+ $art['public'] = Post::has('public');
+ $art['xorg'] = Post::has('xorg');
+ $art['nl'] = Post::has('nl');
+ $art['event'] = Post::v('event');
+ $upload = new PlUpload(S::v('forlife'), 'xnetannounce');
+ $this->upload_image($page, $upload);
+
+ $art['contact_html'] = $art['contacts'];
+ if ($art['event']) {
+ $art['contact_html'] .= "\n{$globals->baseurl}/{$platal->ns}events/sub/{$art['event']}";
+ }
+
+ if (!$art['public'] &&
+ (($art['promo_min'] > $art['promo_max'] && $art['promo_max'] != 0) ||
+ ($art['promo_min'] != 0 && ($art['promo_min'] <= 1900 || $art['promo_min'] >= 2020)) ||
+ ($art['promo_max'] != 0 && ($art['promo_max'] <= 1900 || $art['promo_max'] >= 2020))))
+ {
+ $page->trigError("L'intervalle de promotions est invalide.");
+ Post::kill('valid');
+ }
+
+ if (!trim($art['titre']) || !trim($art['texte'])) {
+ $page->trigError("L'article doit avoir un titre et un contenu.");
+ Post::kill('valid');
+ }
+
+ if (Post::v('valid') == 'Supprimer l\'image') {
+ $upload->rm();
+ Post::kill('valid');
+ }
+ $art['photo'] = $upload->exists() || Post::i('photo');
+ if (Post::v('valid') == 'Pas d\'image' && !is_null($aid)) {
+ XDB::query("DELETE FROM groupex.announces_photo WHERE eid = {?}", $aid);
+ $upload->rm();
+ Post::kill('valid');
+ $art['photo'] = false;
+ }
+ }
+
+ if (Post::v('valid') == 'Enregistrer') {
+ $promo_min = ($art['public'] ? 0 : $art['promo_min']);
+ $promo_max = ($art['public'] ? 0 : $art['promo_max']);
+ $flags = array();
+ if ($art['public']) {
+ $flags[] = 'public';
+ }
+ if ($art['photo']) {
+ $flags[] = 'photo';
+ }
+ $flags = implode(',', $flags);
+ if (is_null($aid)) {
+ $fulltext = $art['texte'];
+ if (!empty($art['contact_html'])) {
+ $fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html'];
+ }
+ $post = null;/*
+ if ($globals->asso('forum')) {
+ require_once 'banana/forum.inc.php';
+ $banana = new ForumsBanana(S::v('forlife'));
+ $post = $banana->post($globals->asso('forum'), null,
+ $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80));
+ }*/
+ XDB::query("INSERT INTO groupex.announces
+ (user_id, asso_id, create_date, titre, texte, contacts,
+ peremption, promo_min, promo_max, flags, post_id)
+ VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+ S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'],
+ $art['peremption'], $promo_min, $promo_max, $flags, $post);
+ $aid = XDB::insertId();
+ if ($art['photo']) {
+ list($imgx, $imgy, $imgtype) = $upload->imageInfo();
+ XDB::execute("INSERT INTO groupex.announces_photo
+ SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}",
+ $aid, $imgtype, $imgx, $imgy, $upload->getContents());
+ }
+ if ($art['xorg']) {
+ require_once('validations.inc.php');
+ $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext,
+ $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid'),
+ $upload);
+ $article->submit();
+ $page->trigWarning("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation.");
+ } else if ($upload && $upload->exists()) {
+ $upload->rm();
+ }
+ if ($art['nl']) {
+ require_once('validations.inc.php');
+ $article = new NLReq(S::v('uid'), $globals->asso('nom') . " : " .$art['titre'],
+ $art['texte'], $art['contact_html']);
+ $article->submit();
+ $page->trigWarning("La parution dans la Lettre Mensuelle est en attente de validation.");
+ }
+ } else {
+ XDB::query("UPDATE groupex.announces
+ SET titre={?}, texte={?}, contacts={?}, peremption={?},
+ promo_min={?}, promo_max={?}, flags={?}
+ WHERE id={?} AND asso_id={?}",
+ $art['titre'], $art['texte'], $art['contacts'], $art['peremption'],
+ $promo_min, $promo_max, $flags,
+ $art['id'], $globals->asso('id'));
+ if ($art['photo'] && $upload->exists()) {
+ list($imgx, $imgy, $imgtype) = $upload->imageInfo();
+ XDB::execute("REPLACE INTO groupex.announces_photo
+ SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}",
+ $aid, $imgtype, $imgx, $imgy, $upload->getContents());
+ $upload->rm();
+ }
+ }
+ }
+ if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') {
+ pl_redirect("");
+ }
+
+ if (empty($art) && !is_null($aid)) {
+ $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife,
+ FIND_IN_SET('public', a.flags) AS public,
+ FIND_IN_SET('photo', a.flags) AS photo
+ FROM groupex.announces AS a
+ INNER JOIN auth_user_md5 AS u USING(user_id)
+ INNER JOIN aliases AS l ON (l.id = u.user_id AND l.type = 'a_vie')
+ WHERE asso_id = {?} AND a.id = {?}",
+ $globals->asso('id'), $aid);
+ if ($res->numRows()) {
+ $art = $res->fetchOneAssoc();
+ $art['contact_html'] = $art['contacts'];
+ } else {
+ $page->kill("Aucun article correspond à l'identifiant indiqué.");
+ }
+ }
+
+ if (is_null($aid)) {
+ $events = XDB::iterator("SELECT *
+ FROM groupex.evenements
+ WHERE asso_id = {?} AND archive = 0",
+ $globals->asso('id'));
+ if ($events->total()) {
+ $page->assign('events', $events);
+ }
+ }
+
+ $art['contact_html'] = @MiniWiki::WikiToHTML($art['contact_html']);
+ $page->assign('art', $art);
+ $page->assign_by_ref('upload', $upload);
+ }
+
+ function handler_admin_announce(&$page)
+ {
+ global $globals;
+ $page->changeTpl('xnetgrp/announce-admin.tpl');
+
+ if (Env::has('del')) {
+ XDB::execute("DELETE FROM groupex.announces
+ WHERE id = {?} AND asso_id = {?}",
+ Env::i('del'), $globals->asso('id'));
+ }
+ $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime
+ FROM groupex.announces AS a
+ WHERE a.asso_id = {?}
+ ORDER BY a.peremption DESC",
+ $globals->asso('id'));
+ $page->assign('articles', $res);
+ }