X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fxnetgrp.php;h=41555f8a638cd4b86354338352178c3c03ff3655;hb=532c06cf78d430c5278df7006335df2921fa98d4;hp=232b2c625043b6d85412a9f6fdb98c5a3e9bbf1d;hpb=faefdbb72b58e3b1867fc7bbdfe8e872d7e8cbc0;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 232b2c6..41555f8 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -122,7 +122,7 @@ class XnetGrpModule extends PLModule if (S::logged()) { if (Env::has('read')) { - XDB::query('DELETE r.* + XDB::query('DELETE groupex.r.* FROM groupex.announces_read AS r INNER JOIN groupex.announces AS a ON a.id = r.announce_id WHERE peremption < CURRENT_DATE()'); @@ -233,7 +233,7 @@ class XnetGrpModule extends PLModule if (Post::has('submit')) { S::assert_xsrf_token(); - $flags = new FlagSet('wiki_desc'); + $flags = new PlFlagSet('wiki_desc'); if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) { $flags->addFlag('notif_unsub'); } @@ -320,10 +320,10 @@ class XnetGrpModule extends PLModule $mls = array_keys(Env::v('ml', array())); $mbr = array_keys(Env::v('membres', array())); - require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php'; + $this->load('mail.inc.php'); set_time_limit(120); $tos = get_all_redirects($mbr, $mls, $mmlist); - $upload = PlUpload::get($_FILES['uploaded'], S::v('forlife'), 'xnet.emails', true); + $upload = PlUpload::get($_FILES['uploaded'], S::user()->login(), 'xnet.emails', true); send_xnet_mails($from, $sujet, $body, Env::v('wiki'), $tos, Post::v('replyto'), $upload, @$_FILES['uploaded']['name']); if ($upload) { $upload->rm(); @@ -708,25 +708,26 @@ class XnetGrpModule extends PLModule if (Env::has('right') && (may_update() || S::has('suid'))) { switch (Env::v('right')) { case 'admin': - XnetSession::killSuid(); + Platal::session()->stopSUID(); break; case 'anim': - XnetSession::doSelfSuid(); + Platal::session()->doSelfSuid(); may_update(true); is_member(true); break; case 'member': - XnetSession::doSelfSuid(); + Platal::session()->doSelfSuid(); may_update(false, true); is_member(true); break; case 'logged': - XnetSession::doSelfSuid(); + Platal::session()->doSelfSuid(); may_update(false, true); is_member(false, true); break; } } +// var_dump($_SESSION); http_redirect($_SERVER['HTTP_REFERER']); } @@ -734,7 +735,7 @@ class XnetGrpModule extends PLModule { global $globals; - require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php'; + $this->load('mail.inc.php'); $page->changeTpl('xnetgrp/annuaire-admin.tpl'); $mmlist = new MMList(S::v('uid'), S::v('password'), $globals->asso('mail_domain')); @@ -789,29 +790,15 @@ class XnetGrpModule extends PLModule S::assert_xsrf_token(); } - 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."); + if (!User::isForeignEmailAddress($email)) { + $user = User::get($email); + if ($user) { + XDB::execute("REPLACE INTO groupex.membres (uid, asso_id, origine) + VALUES ({?}, {?}, 'X')", + $user->id(), $globals->asso('id')); + pl_redirect("member/" . $user->login()); } } 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'); @@ -884,7 +871,7 @@ class XnetGrpModule extends PLModule function unsubscribe(&$user) { - global $globals, $page; + global $globals; XDB::execute( "DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}", $user['uid'], $globals->asso('id')); @@ -928,9 +915,9 @@ class XnetGrpModule extends PLModule $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']}@ !"); + Platal::page()->trigWarning("{$user['prenom']} {$user['nom']} a une" + ." demande d'inscription en cours sur la" + ." liste {$liste['list']}@ !"); $warning = true; } } @@ -989,7 +976,7 @@ class XnetGrpModule extends PLModule } } - private function changeLogin(PlatalPage &$page, array &$user, MMList &$mmlist, $login) + private function changeLogin(PlPage &$page, array &$user, MMList &$mmlist, $login) { require_once 'user.func.inc.php'; // Search the uid of the user... @@ -1183,32 +1170,14 @@ class XnetGrpModule extends PLModule 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); + + $this->load('feed.inc.php'); + $feed = new XnetGrpEventFeed(); + return $feed->run($page, $user, $hash, false); } - private function upload_image(PlatalPage &$page, PlUpload &$upload) + private function upload_image(PlPage &$page, PlUpload &$upload) { if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) { return true; @@ -1237,7 +1206,7 @@ class XnetGrpModule extends PLModule exit; } } else { - $upload = new PlUpload(S::v('forlife'), 'xnetannounce'); + $upload = new PlUpload(S::user()->login(), 'xnetannounce'); if ($upload->exists() && $upload->isType('image')) { header('Content-Type: ' . $upload->contentType()); echo $upload->getContents(); @@ -1278,7 +1247,7 @@ class XnetGrpModule extends PLModule $art['xorg'] = Post::has('xorg'); $art['nl'] = Post::has('nl'); $art['event'] = Post::v('event'); - $upload = new PlUpload(S::v('forlife'), 'xnetannounce'); + $upload = new PlUpload(S::user()->login(), 'xnetannounce'); $this->upload_image($page, $upload); $art['contact_html'] = $art['contacts']; @@ -1316,7 +1285,7 @@ class XnetGrpModule extends PLModule if (Post::v('valid') == 'Enregistrer') { $promo_min = ($art['public'] ? 0 : $art['promo_min']); $promo_max = ($art['public'] ? 0 : $art['promo_max']); - $flags = new FlagSet(); + $flags = new PlFlagSet(); if ($art['public']) { $flags->addFlag('public'); } @@ -1331,7 +1300,7 @@ class XnetGrpModule extends PLModule $post = null;/* if ($globals->asso('forum')) { require_once 'banana/forum.inc.php'; - $banana = new ForumsBanana(S::v('forlife')); + $banana = new ForumsBanana(S::user()); $post = $banana->post($globals->asso('forum'), null, $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80)); }*/ @@ -1351,7 +1320,7 @@ class XnetGrpModule extends PLModule 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'), + $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::user(), $upload); $article->submit(); $page->trigWarning("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation."); @@ -1360,7 +1329,7 @@ class XnetGrpModule extends PLModule } if ($art['nl']) { require_once('validations.inc.php'); - $article = new NLReq(S::v('uid'), $globals->asso('nom') . " : " .$art['titre'], + $article = new NLReq(S::user(), $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.");