Env::i('unread'), S::i('uid'));
pl_redirect("#art" . Env::i('unread'));
}
- $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife,
+ $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo, u.hruid,
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 (u.user_id = l.id AND l.type = 'a_vie')
LEFT JOIN groupex.announces_read AS r ON (r.user_id = {?} AND r.announce_id = a.id)
WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
AND (promo_min = 0 OR promo_min <= {?})
$platal->ns . "rss/rss.xml");
} else {
$page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News",
- $platal->ns . 'rss/'.S::v('forlife') .'/'.S::v('core_rss_hash').'/rss.xml');
+ $platal->ns . 'rss/'.S::v('hruid') .'/'.S::v('core_rss_hash').'/rss.xml');
}
$page->assign('articles', $arts);
if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) {
$flags->addFlag('notif_unsub');
}
+ $site = trim(Post::v('site'));
+ if ($site && ($site != "http://")) {
+ $scheme = parse_url($site, PHP_URL_SCHEME);
+ if (!$scheme) {
+ $site = "http://" . $site;
+ }
+ } else {
+ $site = "";
+ }
if (S::has_perms()) {
if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) {
$page->trigError("le domaine doit être un FQDN (aucune modif effectuée) !!!");
WHERE id={?}",
Post::v('nom'), Post::v('diminutif'),
Post::v('cat'), Post::i('dom'),
- Post::v('descr'), Post::v('site'),
+ Post::v('descr'), $site,
Post::v('mail'), Post::v('resp'),
Post::v('forum'), Post::v('mail_domain'),
Post::has('ax'), Post::v('pub'),
forum={?}, ax={?}, pub= {?}, sub_url={?},
unsub_url={?},flags={?}
WHERE id={?}",
- Post::v('descr'), Post::v('site'),
+ Post::v('descr'), $site,
Post::v('mail'), Post::v('resp'),
Post::v('forum'), Post::has('ax'),
Post::v('pub'),
$mmlist = new MMList(S::v('uid'), S::v('password'),
$globals->asso('mail_domain'));
$page->assign('listes', $mmlist->get_lists());
+ $page->assign('user', S::user());
$page->addJsLink('ajax.js');
if (Post::has('send')) {
$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();
$globals->asso('id'), $uid);
}
- private function validSubscription($nom, $prenom, $sexe, $uid, $forlife)
+ private function validSubscription(User &$user)
{
global $globals;
- $this->removeSubscriptionRequest($uid);
+ $this->removeSubscriptionRequest($user->id());
XDB::execute("INSERT INTO groupex.membres (asso_id, uid)
VALUES ({?}, {?})",
- $globals->asso('id'), $uid);
+ $globals->asso('id'), $user->id());
$mailer = new PlMailer();
- $mailer->addTo("$forlife@polytechnique.org");
- $mailer->setFrom('"' . S::v('prenom') . ' ' . S::v('nom')
- . '" <' . S::v('forlife') . '@polytechnique.org>');
+ $mailer->addTo($user->forlifeEmail());
+ $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
$mailer->setSubject('[' . $globals->asso('nom') . '] Demande d\'inscription');
- $message = ($sexe ? 'Chère' : 'Cher') . " Camarade,\n"
+ $message = ($user->isFemale() ? 'Chère' : 'Cher') . " Camarade,\n"
. "\n"
. " Suite à ta demande d'adhésion à " . $globals->asso('nom') . ",\n"
. "j'ai le plaisir de t'annoncer que ton inscription a été validée !\n"
. "\n"
. "Bien cordialement,\n"
. "-- \n"
- . S::s('prenom') . ' ' . S::s('nom') . '.';
+ . S::user()->fullName() . '.';
$mailer->setTxtBody($message);
$mailer->send();
}
."sur la page de présentation.");
if (!is_null($u) && may_update()) {
- $page->assign('u', $u);
- $res = XDB::query("SELECT u.nom, u.prenom, u.promo, u.user_id, FIND_IN_SET('femme', u.flags), s.reason
- FROM auth_user_md5 AS u
- INNER JOIN aliases AS al ON (al.id = u.user_id AND al.type != 'liste')
- LEFT JOIN groupex.membres_sub_requests AS s ON (u.user_id = s.uid AND s.asso_id = {?})
- WHERE al.alias = {?}", $globals->asso('id'), $u);
-
- if (list($nom, $prenom, $promo, $uid, $sexe, $reason) = $res->fetchOneRow()) {
- $res = XDB::query("SELECT COUNT(*)
- FROM groupex.membres AS m
- INNER JOIN aliases AS a ON (m.uid = a.id AND a.type != 'homonyme')
- WHERE a.alias = {?} AND m.asso_id = {?}",
- $u, $globals->asso('id'));
- $n = $res->fetchOneCell();
- if ($n) {
- $this->removeSubscriptionRequest($uid);
- $page->kill("$prenom $nom est déjà membre du groupe !");
- return;
- } elseif (Env::has('accept')) {
- S::assert_xsrf_token();
-
- $this->validSubscription($nom, $prenom, $sexe, $uid, $u);
- pl_redirect("member/$u");
- } elseif (Env::has('refuse')) {
- S::assert_xsrf_token();
-
- $this->removeSubscriptionRequest($uid);
- $mailer = new PlMailer();
- $mailer->addTo("$u@polytechnique.org");
- $mailer->setFrom('"'.S::v('prenom').' '.S::v('nom')
- .'" <'.S::v('forlife').'@polytechnique.org>');
- $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée');
- $mailer->setTxtBody(Env::v('motif'));
- $mailer->send();
- $page->kill("La demande de $prenom $nom a bien été refusée.");
- } else {
- $page->assign('show_form', true);
- $page->assign('prenom', $prenom);
- $page->assign('nom', $nom);
- $page->assign('promo', $promo);
- $page->assign('uid', $uid);
- $page->assign('reason', $reason);
- }
- return;
+ $user = User::get($u);
+ if (!$user) {
+ return PL_NOT_FOUND;
+ } else {
+ $page->assign('user', $user);
}
- return PL_NOT_FOUND;
+
+ // Retrieves the subscription status, and the reason.
+ $res = XDB::query("SELECT reason
+ FROM groupex.membres_sub_requests
+ WHERE asso_id = {?} AND uid = {?}",
+ $globals->asso('id'), $user->id());
+ $reason = ($res->numRows() ? $res->fetchOneCell() : null);
+
+ $res = XDB::query("SELECT COUNT(*)
+ FROM groupex.membres
+ WHERE asso_id = {?} AND uid = {?}",
+ $globals->asso('id'), $user->id());
+ $already_member = ($res->fetchOneCell() > 0);
+
+ // Handles the membership request.
+ if ($already_member) {
+ $this->removeSubscriptionRequest($user->id());
+ $page->kill($user->fullName() . " est déjà membre du groupe !");
+ } elseif (Env::has('accept')) {
+ S::assert_xsrf_token();
+
+ $this->validSubscription($user);
+ pl_redirect("member/" . $user->login());
+ } elseif (Env::has('refuse')) {
+ S::assert_xsrf_token();
+
+ $this->removeSubscriptionRequest($user->id());
+ $mailer = new PlMailer();
+ $mailer->addTo($user->forlifeEmail());
+ $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
+ $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée');
+ $mailer->setTxtBody(Env::v('motif'));
+ $mailer->send();
+ $page->kill("La demande de {$user->fullName()} a bien été refusée.");
+ } else {
+ $page->assign('show_form', true);
+ $page->assign('reason', $reason);
+ }
+ return;
}
if (is_member()) {
$append = "\n"
. "-- \n"
. "Ce message a été envoyé suite à la demande d'inscription de\n"
- . S::v('prenom').' '.S::v('nom').' (X'.S::v('promo').")\n"
+ . S::user()->fullName() . ' (X' . S::v('promo') . ")\n"
. "Via le site www.polytechnique.net. Tu peux choisir de valider ou\n"
. "de refuser sa demande d'inscription depuis la page :\n"
- .
- "http://www.polytechnique.net/".$globals->asso("diminutif")."/subscribe/"
- .S::v('forlife')."\n"
+ . "http://www.polytechnique.net/" . $globals->asso("diminutif") . "/subscribe/" . S::user()->login() . "\n"
. "\n"
. "En cas de problème, contacter l'équipe de Polytechnique.org\n"
. "à l'adresse : support@polytechnique.org\n";
$mailer = new PlMailer();
$mailer->addTo($to);
- $mailer->setFrom('"'.S::v('prenom').' '.S::v('nom')
- .'" <'.S::v('forlife').'@polytechnique.org>');
+ $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
$mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription');
$mailer->setTxtBody(Post::v('message').$append);
$mailer->send();
$subs = Post::v('subs');
if (is_array($subs)) {
$users = array();
- foreach ($subs as $forlife => $val) {
+ foreach ($subs as $hruid => $val) {
if ($val == '1') {
- $res = XDB::query("SELECT IF(u.nom_usage != '', u.nom_usage, u.nom) AS u,
- u.prenom, FIND_IN_SET('femme', u.flags) AS sexe,
- u.user_id
- FROM auth_user_md5 AS u
- INNER JOIN aliases AS a ON (a.id = u.user_id)
- WHERE a.alias = {?}", $forlife);
- if ($res->numRows() == 1) {
- list($nom, $prenom, $sexe, $uid) = $res->fetchOneRow();
- $this->validSubscription($nom, $prenom, $sexe, $uid, $forlife);
+ $user = User::get($hruid);
+ if ($user) {
+ $this->validSubscription($user);
}
}
}
}
$it = XDB::iterator("SELECT IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom,
- u.prenom, u.promo, a.alias AS forlife, s.ts AS date
+ u.prenom, u.promo, u.hruid, s.ts AS date
FROM groupex.membres_sub_requests AS s
INNER JOIN auth_user_md5 AS u ON (s.uid = u.user_id)
- INNER JOIN aliases AS a ON (a.id = s.uid AND a.type = 'a_vie')
WHERE asso_id = {?}
ORDER BY nom, prenom",
$globals->asso('id'));
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 {
if (isvalid_email($email)) {
function handler_unsubscribe(&$page)
{
$page->changeTpl('xnetgrp/membres-del.tpl');
- $user = get_infos(S::v('forlife'));
+ $user = get_infos(S::user()->id());
if (empty($user)) {
return PL_NOT_FOUND;
}
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();
$art['nom'] = S::v('nom');
$art['prenom'] = S::v('prenom');
$art['promo'] = S::v('promo');
- $art['forlife'] = S::v('forlife');
+ $art['hruid'] = S::user()->login();
$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');
+ $upload = new PlUpload(S::user()->login(), 'xnetannounce');
$this->upload_image($page, $upload);
$art['contact_html'] = $art['contacts'];
$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));
}*/
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.");
}
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.");
}
if (empty($art) && !is_null($aid)) {
- $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife,
+ $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, u.hruid,
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()) {