X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=6d34a5447b777403d2f644221aa3f09cebd20dc0;hb=baa62e58cdfb6839040e156ef91e2827bdde1600;hp=d4a961217397c8855480570f8aa6f2c0fae7a612;hpb=02fdd1c889526931990ed2f1cae1fc9a8b2d9459;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index d4a9612..6d34a54 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -41,12 +41,12 @@ function get_infos($email) if ($res->numRows()) { $user = $res->fetchOneAssoc(); if ($user['origine'] == 'X') { - $res = XDB::query("SELECT nom, prenom, promo, FIND_IN_SET(flags, 'femme') AS sexe + $res = XDB::query("SELECT nom, prenom, promo, FIND_IN_SET('femme', flags) AS sexe FROM auth_user_md5 WHERE user_id = {?}", $user['uid']); $user = array_merge($user, $res->fetchOneAssoc()); } - return $user; + return $user; } elseif ($dom == 'polytechnique.org' || $dom == 'm4x.org') { $res = XDB::query( "SELECT user_id AS uid, u.promo, @@ -55,7 +55,7 @@ function get_infos($email) CONCAT(b.alias, '@m4x.org') AS email, CONCAT(b.alias, '@polytechnique.org') AS email2, m.perms='admin' AS perms, m.origine, - FIND_IN_SET(u.flags, 'femme') AS sexe + FIND_IN_SET('femme', u.flags) AS sexe FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( u.user_id = a.id AND a.type != 'homonyme' ) INNER JOIN aliases AS b ON ( u.user_id = b.id AND b.type = 'a_vie' ) @@ -77,33 +77,34 @@ class XnetGrpModule extends PLModule '%grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC), '%grp/logo' => $this->make_hook('logo', AUTH_PUBLIC), '%grp/site' => $this->make_hook('site', AUTH_PUBLIC), - '%grp/edit' => $this->make_hook('edit', AUTH_MDP), - '%grp/mail' => $this->make_hook('mail', AUTH_MDP), - '%grp/forum' => $this->make_hook('forum', AUTH_MDP), - '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP), - '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP), - '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP), + '%grp/edit' => $this->make_hook('edit', AUTH_MDP, 'groupadmin'), + '%grp/mail' => $this->make_hook('mail', AUTH_MDP, 'groupadmin'), + '%grp/forum' => $this->make_hook('forum', AUTH_MDP, 'groupmember'), + '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP, 'groupannu'), + '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP, 'groupmember:groupannu'), + '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP, 'groupannu'), + '%grp/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'groupannu'), '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP), - '%grp/unsubscribe' => $this->make_hook('unsubscribe', AUTH_MDP), + '%grp/unsubscribe' => $this->make_hook('unsubscribe', AUTH_MDP, 'groupmember'), '%grp/change_rights' => $this->make_hook('change_rights', AUTH_MDP), '%grp/admin/annuaire' - => $this->make_hook('admin_annuaire', AUTH_MDP), + => $this->make_hook('admin_annuaire', AUTH_MDP, 'groupadmin'), '%grp/member' - => $this->make_hook('admin_member', AUTH_MDP), + => $this->make_hook('admin_member', AUTH_MDP, 'groupadmin'), '%grp/member/new' - => $this->make_hook('admin_member_new', AUTH_MDP), + => $this->make_hook('admin_member_new', AUTH_MDP, 'groupadmin'), '%grp/member/new/ajax' - => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH), + => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH), '%grp/member/del' - => $this->make_hook('admin_member_del', AUTH_MDP), + => $this->make_hook('admin_member_del', AUTH_MDP, 'groupadmin'), - '%grp/rss' => $this->make_hook('rss', AUTH_PUBLIC), - '%grp/announce/new' => $this->make_hook('edit_announce', AUTH_MDP), - '%grp/announce/edit' => $this->make_hook('edit_announce', AUTH_MDP), - '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_MDP), + '%grp/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), + '%grp/announce/new' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'), + '%grp/announce/edit' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'), + '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_MDP, 'groupadmin'), ); } @@ -114,15 +115,14 @@ class XnetGrpModule extends PLModule if (!is_null($arg)) { return PL_NOT_FOUND; } - - new_group_open_page('xnetgrp/asso.tpl'); + $page->changeTpl('xnetgrp/asso.tpl'); if (S::logged()) { if (Env::has('read')) { XDB::query('DELETE r.* FROM groupex.announces_read AS r INNER JOIN groupex.announces AS a ON a.id = r.announce_id - WHERE peremption < CURRENT_DATE()'); + WHERE peremption < CURRENT_DATE()'); XDB::query('INSERT INTO groupex.announces_read VALUES ({?}, {?})', Env::i('read'), S::i('uid')); @@ -159,7 +159,7 @@ class XnetGrpModule extends PLModule FROM groupex.announces AS a INNER JOIN auth_user_md5 AS u USING(user_id) WHERE asso_id = {?} AND peremption >= CURRENT_DATE() - AND FIND_IN_SET(a.flags, 'public')", + AND FIND_IN_SET('public', u.flags)", $globals->asso('id')); } @@ -170,11 +170,8 @@ class XnetGrpModule extends PLModule $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News", 'rss/'.S::v('forlife') .'/'.S::v('core_rss_hash').'/rss.xml'); } - - $page->register_modifier('url_catcher', array(MiniWiki,'WikiToHTML')); - $page->assign('articles', $arts); - $page->assign('asso', $globals->asso()); + $page->assign('articles', $arts); } function handler_logo(&$page) @@ -220,8 +217,7 @@ class XnetGrpModule extends PLModule function handler_edit(&$page) { global $globals; - - new_groupadmin_page('xnetgrp/edit.tpl'); + $page->changeTpl('xnetgrp/edit.tpl'); if (Post::has('submit')) { if (S::has_perms()) { @@ -234,14 +230,15 @@ class XnetGrpModule extends PLModule SET nom={?}, diminutif={?}, cat={?}, dom={?}, descr={?}, site={?}, mail={?}, resp={?}, forum={?}, mail_domain={?}, ax={?}, pub={?}, - sub_url={?}, inscriptible={?}, unsub_url={?} + sub_url={?}, inscriptible={?}, unsub_url={?}, + flags='wiki_desc' WHERE id={?}", Post::v('nom'), Post::v('diminutif'), Post::v('cat'), Post::i('dom'), Post::v('descr'), Post::v('site'), Post::v('mail'), Post::v('resp'), Post::v('forum'), Post::v('mail_domain'), - Post::has('ax'), Post::has('pub')?'private':'public', + Post::has('ax'), Post::v('pub'), Post::v('sub_url'), Post::v('inscriptible'), Post::v('unsub_url'),$globals->asso('id')); if (Post::v('mail_domain')) { @@ -253,12 +250,12 @@ class XnetGrpModule extends PLModule "UPDATE groupex.asso SET descr={?}, site={?}, mail={?}, resp={?}, forum={?}, ax={?}, pub= {?}, sub_url={?}, - unsub_url={?} + unsub_url={?},flags='wiki_desc' WHERE id={?}", Post::v('descr'), Post::v('site'), Post::v('mail'), Post::v('resp'), Post::v('forum'), Post::has('ax'), - Post::has('pub')?'private':'public', + Post::has('pub'), Post::v('sub_url'), Post::v('unsub_url'), $globals->asso('id')); } @@ -267,9 +264,9 @@ class XnetGrpModule extends PLModule $logo = file_get_contents($_FILES['logo']['tmp_name']); $mime = $_FILES['logo']['type']; XDB::execute('UPDATE groupex.asso - SET logo={?}, logo_mime={?} - WHERE id={?}', $logo, $mime, - $globals->asso('id')); + SET logo={?}, logo_mime={?} + WHERE id={?}', $logo, $mime, + $globals->asso('id')); } pl_redirect('../'.Post::v('diminutif', $globals->asso('diminutif')).'/edit'); @@ -280,16 +277,22 @@ class XnetGrpModule extends PLModule $page->assign('dom', $dom); $page->assign('super', true); } + if (!$globals->asso('wiki_desc') && $globals->asso('descr')) { + $page->trig("Attention, le format de la description a changé et utilise désormais la syntaxe wiki " + . "intégrée au site. Il te faudra probablement adapter le formatage du texte actuelle pour " + . "qu'il s'affiche correctement avec cette nouvelle syntaxe."); + } } function handler_mail(&$page) { global $globals; - new_groupadmin_page('xnetgrp/mail.tpl'); + $page->changeTpl('xnetgrp/mail.tpl'); $mmlist = new MMList(S::v('uid'), S::v('password'), $globals->asso('mail_domain')); $page->assign('listes', $mmlist->get_lists()); + $page->addJsLink('ajax.js'); if (Post::has('send')) { $from = Post::v('from'); @@ -301,7 +304,11 @@ class XnetGrpModule extends PLModule require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php'; $tos = get_all_redirects($mbr, $mls, $mmlist); - send_xnet_mails($from, $sujet, $body, $tos, Post::v('replyto'), $_FILES['uploaded']); + $upload = PlUpload::get($_FILES['uploaded'], S::v('forlife'), 'xnet.emails', true); + send_xnet_mails($from, $sujet, $body, Env::v('wiki'), $tos, Post::v('replyto'), $upload, @$_FILES['uploaded']['name']); + if ($upload) { + $upload->rm(); + } $page->kill("Mail envoyé !"); $page->assign('sent', true); } @@ -310,7 +317,7 @@ class XnetGrpModule extends PLModule function handler_forum(&$page, $group = null, $artid = null) { global $globals; - new_group_page('xnetgrp/forum.tpl'); + $page->changeTpl('xnetgrp/forum.tpl'); if (!$globals->asso('forum')) { return PL_NOT_FOUND; } @@ -320,10 +327,23 @@ class XnetGrpModule extends PLModule run_banana($page, 'ForumsBanana', $get); } - function handler_annuaire(&$page) + function handler_annuaire(&$page, $action = null, $subaction = null) { global $globals; - new_annu_page('xnetgrp/annuaire.tpl'); + + if ($action == 'search') { + http_redirect("https://www.polytechnique.org/search/adv?rechercher=Chercher&groupex={$globals->asso('id')}" + . "&cityid=" . Env::v('cityid') . "&mapid=" . Env::v('mapid')); + } else if ($action == 'geoloc' || $action == 'trombi') { + $view = new UserSet(); + $view->addMod('trombi', 'Trombinoscope'); + $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'annuaire/search')); + $view->apply('annuaire', $page, $action, $subaction); + if ($action == 'geoloc' && $subaction) { + return; + } + } + $page->changeTpl('xnetgrp/annuaire.tpl'); $sort = Env::v('order'); switch (Env::v('order')) { @@ -341,7 +361,7 @@ class XnetGrpModule extends PLModule 1, 1)) as letter, COUNT(*) FROM groupex.membres AS m LEFT JOIN auth_user_md5 AS u ON ( u.user_id = m.uid) - WHERE asso_id = {?} and u.perms != \'pending\' + WHERE asso_id = {?} and (u.perms != \'pending\' OR u.perms IS NULL) GROUP BY letter ORDER BY letter', $globals->asso('id')); } else { @@ -409,77 +429,44 @@ class XnetGrpModule extends PLModule m.perms='admin' AS admin, m.origine='X' AS x, u.perms!='pending' AS inscrit, - m.uid, e.email AS actif + m.uid, IF(e.email IS NULL,NULL,1) AS actif FROM groupex.membres AS m LEFT JOIN auth_user_md5 AS u ON ( u.user_id = m.uid ) LEFT JOIN aliases AS a ON ( a.id = m.uid AND a.type='a_vie' ) LEFT JOIN emails AS e ON ( e.flags = 'active' AND e.uid = m.uid) WHERE m.asso_id = {?} $ini AND (m.origine != 'X' OR u.perms != 'pending' OR m.email IS NOT NULL) - GROUP BY m.uid + GROUP BY m.uid ORDER BY $tri LIMIT {?},{?}", $globals->asso('id'), $ofs*NB_PER_PAGE, NB_PER_PAGE); $page->assign('ann', $ann); + $page->jsonAssign('ann', $ann); } - function handler_trombi(&$page, $num = 1) + function handler_trombi(&$page) { - global $globals; - new_annu_page('xnetgrp/trombi.tpl'); - - $page->assign('urlmainsite', "https://www.polytechnique.org/"); - $trombi = new Trombi(array($this, '_trombi_getlist')); - $trombi->hidePromo(); - $trombi->setAdmin(); - $page->assign_by_ref('trombi', $trombi); + pl_redirect('annuaire/trombi'); } - function _trombi_getlist($offset, $limit) + function handler_geoloc(&$page) { - global $globals; - $where = "WHERE m.asso_id= '".addslashes($globals->asso('id'))."'"; - - $res = XDB::query( - "SELECT COUNT(*) - FROM auth_user_md5 AS u - RIGHT JOIN photo AS p ON u.user_id=p.uid - INNER JOIN groupex.membres AS m ON (m.uid = u.user_id) - $where"); - $pnb = $res->fetchOneCell(); - - $res = XDB::query("SELECT promo, user_id, a.alias AS forlife, - IF (nom_usage='', u.nom, nom_usage) AS nom, u.prenom - FROM photo AS p - INNER JOIN auth_user_md5 AS u ON u.user_id=p.uid - INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' ) - INNER JOIN groupex.membres AS m ON (m.uid = u.user_id) - $where - ORDER BY promo, u.nom, u.prenom LIMIT {?}, {?}", $offset*$limit, $limit); - - return array($pnb, $res->fetchAllAssoc()); + pl_redirect('annuaire/geoloc'); } - + function handler_vcard(&$page, $photos = null) { global $globals; - - if (($globals->asso('pub') == 'public' && is_member()) || may_update()) { - $res = XDB::query('SELECT uid - FROM groupex.membres - WHERE asso_id = {?}', $globals->asso('id')); - require_once('vcard.inc.php'); - $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom')); - $vcard->do_page($page); - } else { - return PL_FORBIDDEN; - } + $res = XDB::query('SELECT uid + FROM groupex.membres + WHERE asso_id = {?}', $globals->asso('id')); + $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom')); + $vcard->do_page($page); } function handler_subscribe(&$page, $u = null) { global $globals; - - new_group_open_page('xnetgrp/inscrire.tpl'); + $page->changeTpl('xnetgrp/inscrire.tpl'); if (!$globals->asso('inscriptible')) $page->kill("Il n'est pas possible de s'inscire en ligne à ce " @@ -601,7 +588,7 @@ class XnetGrpModule extends PLModule { if (Env::has('right') && (may_update() || S::has('suid'))) { switch (Env::v('right')) { - case 'admin': + case 'admin': XnetSession::killSuid(); break; case 'anim': @@ -610,7 +597,7 @@ class XnetGrpModule extends PLModule is_member(true); break; case 'member': - XnetSession::doSelfSuid(); + XnetSession::doSelfSuid(); may_update(false, true); is_member(true); break; @@ -629,8 +616,7 @@ class XnetGrpModule extends PLModule global $globals; require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php'; - - new_groupadmin_page('xnetgrp/annuaire-admin.tpl'); + $page->changeTpl('xnetgrp/annuaire-admin.tpl'); $mmlist = new MMList(S::v('uid'), S::v('password'), $globals->asso('mail_domain')); $lists = $mmlist->get_lists(); @@ -675,7 +661,7 @@ class XnetGrpModule extends PLModule { global $globals; - new_groupadmin_page('xnetgrp/membres-add.tpl'); + $page->changeTpl('xnetgrp/membres-add.tpl'); $page->addJsLink('ajax.js'); if (is_null($email)) { @@ -699,7 +685,7 @@ class XnetGrpModule extends PLModule 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/$email"); + pl_redirect("member/$forlife"); } else { $page->trig($email." n'est pas un alias polytechnique.org valide"); } @@ -712,22 +698,17 @@ class XnetGrpModule extends PLModule FROM auth_user_md5 WHERE user_id = {?} AND perms = 'pending'", $uid); if ($res->numRows() == 1) { - XDB::execute('INSERT INTO groupex.membres (uid, asso_id, origine, email) - VALUES ({?}, {?}, "X", {?})', - $uid, $globals->asso('id'), $email); if (Env::v('market')) { - $res = XDB::query('SELECT COUNT(*) - FROM register_marketing - WHERE uid={?} AND email={?}', $uid, $email); - if (!$res->fetchOneCell()) { - XDB::execute("INSERT INTO register_marketing (uid,sender,email,date,last,nb,type,hash) - VALUES ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')", - $uid, S::v('uid'), $email, Env::v('market_from')); - require_once('validations.inc.php'); - $req = new MarkReq(S::v('uid'), $uid, $email, Env::v('market_from') == 'user'); - $req->submit(); - } + $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->trig("Utilisateur invalide"); @@ -749,22 +730,31 @@ class XnetGrpModule extends PLModule { header('Content-Type: text/html; charset="UTF-8"'); $page->changeTpl('xnetgrp/membres-new-search.tpl', NO_SKIN); - 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%'"; + $res = null; + if (Env::has('login')) { + require_once 'user.func.inc.php'; + $res = get_not_registered_user(Env::v('login'), true); } - if (preg_match('/^[0-9]{4}$/', Env::v('promo'))) { - $where .= " AND promo = " . Env::i('promo'); - } elseif (Env::has('promo')) { - return; + 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"); } - $res = XDB::iterator("SELECT user_id, nom, prenom, promo - FROM auth_user_md5 - WHERE $where"); if ($res->total() < 30) { $page->assign("choix", $res); } @@ -814,7 +804,7 @@ class XnetGrpModule extends PLModule function handler_unsubscribe(&$page) { - new_group_page('xnetgrp/membres-del.tpl'); + $page->changeTpl('xnetgrp/membres-del.tpl'); $user = get_infos(S::v('forlife')); if (empty($user)) { return PL_NOT_FOUND; @@ -836,7 +826,7 @@ class XnetGrpModule extends PLModule function handler_admin_member_del(&$page, $user = null) { - new_groupadmin_page('xnetgrp/membres-del.tpl'); + $page->changeTpl('xnetgrp/membres-del.tpl'); $user = get_infos($user); if (empty($user)) { return PL_NOT_FOUND; @@ -854,11 +844,77 @@ class XnetGrpModule extends PLModule } } + 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->trig("Le login $login ne correspond à aucun X"); + return false; + } else if (count($x) > 1) { + $page->trig("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, '@', 2) = {?}) + 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, '@', 2) = {?}) + WHERE vr.redirect = {?}", + $globals->asso('mail_domain'), $user['email']); + foreach (Env::v('ml1', array()) as $ml => $state) { + $mmlist->replace_email($ml, $user['email'], $email); + } + } + return $login; + } + function handler_admin_member(&$page, $user) { global $globals; - new_groupadmin_page('xnetgrp/membres-edit.tpl'); + $page->changeTpl('xnetgrp/membres-edit.tpl'); $user = get_infos($user); if (empty($user)) { @@ -869,6 +925,15 @@ class XnetGrpModule extends PLModule $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') { @@ -896,6 +961,7 @@ class XnetGrpModule extends PLModule $page->trig('permissions modifiées'); } + // Update ML subscriptions foreach (Env::v('ml1', array()) as $ml => $state) { $ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2; if ($ask == $state) { @@ -922,6 +988,7 @@ class XnetGrpModule extends PLModule } } + // Change subscriptioin to aliases foreach (Env::v('ml3', array()) as $ml => $state) { $ask = !empty($_REQUEST['ml4'][$ml]); if($state == $ask) continue; @@ -959,7 +1026,6 @@ class XnetGrpModule extends PLModule global $globals; require_once('rss.inc.php'); $uid = init_rss('xnetgrp/announce-rss.tpl', $user, $hash, false); - $page->register_modifier('url_catcher', array(MiniWiki,'WikiToHTML')); if ($uid) { $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.contacts, a.create_date, @@ -975,7 +1041,7 @@ class XnetGrpModule extends PLModule 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(a.flags, 'public') AND peremption >= NOW() AND a.asso_id = {?}", + WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}", $globals->asso('id')); } $page->assign('asso', $globals->asso()); @@ -985,8 +1051,7 @@ class XnetGrpModule extends PLModule function handler_edit_announce(&$page, $aid = null) { global $globals, $platal; - new_groupadmin_page('xnetgrp/announce-edit.tpl'); - $page->register_modifier('url_catcher', array(MiniWiki,'WikiToHTML')); + $page->changeTpl('xnetgrp/announce-edit.tpl'); $page->assign('new', is_null($aid)); $art = array(); @@ -1033,17 +1098,27 @@ class XnetGrpModule extends PLModule $promo_min = ($art['public'] ? 0 : $art['promo_min']); $promo_max = ($art['public'] ? 0 : $art['promo_max']); 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) - VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})", + 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, $art['public'] ? 'public' : ''); + $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : '', $post); $aid = XDB::insertId(); if ($art['xorg']) { require_once('validations.inc.php'); - $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], - MiniWiki::WikiToHTML($art['texte'] . (!empty($art['contact_html']) ? "\n\nContacts :\n" . $art['contact_html'] : "")), + $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext, $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid')); $article->submit(); $page->trig("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation"); @@ -1067,11 +1142,11 @@ class XnetGrpModule extends PLModule } 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(a.flags, 'public') AS public + FIND_IN_SET('public', a.flags) AS public 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') @@ -1085,22 +1160,6 @@ class XnetGrpModule extends PLModule } } - $select = ''; - for ($i = 1 ; $i < 30 ; $i++) { - $time = time() + 3600 * 24 * $i; - $p_stamp = date('Ymd', $time); - $year = date('Y', $time); - $month = date('m', $time); - $day = date('d', $time); - - $select .= "\n"; - } - $page->assign('select', $select); - if (is_null($aid)) { $events = XDB::iterator("SELECT * FROM groupex.evenements @@ -1109,26 +1168,26 @@ class XnetGrpModule extends PLModule if ($events->total()) { $page->assign('events', $events); } - } + } - $art['contact_html'] = MiniWiki::WikiToHTML($art['contact_html']); + $art['contact_html'] = @MiniWiki::WikiToHTML($art['contact_html']); $page->assign('art', $art); } function handler_admin_announce(&$page) { global $globals; - new_groupadmin_page('xnetgrp/announce-admin.tpl'); + $page->changeTpl('xnetgrp/announce-admin.tpl'); if (Env::has('del')) { - XDB::execute("DELETE FROM groupex.announces - WHERE id = {?} AND asso_id = {?}", + 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", + $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); }