From: Pierre Habouzit (MadCoder Date: Thu, 21 Apr 2005 19:13:50 +0000 (+0000) Subject: yet another x.net page ! X-Git-Tag: xorg/old~175 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4d7da7d35127d81fe465f9d2fb4fe63fa732d893;p=platal.git yet another x.net page ! git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-587 --- diff --git a/htdocs.net/groupe/inscrire.php b/htdocs.net/groupe/inscrire.php new file mode 100644 index 0000000..81f407f --- /dev/null +++ b/htdocs.net/groupe/inscrire.php @@ -0,0 +1,101 @@ +useMenu(); +$page->setType($globals->asso('cat')); +$page->assign('asso', $globals->asso()); +$page->assign('admin', may_update()); + + +if (Env::has('u') && may_update()) { + $u = Env::get('u'); + $res = $globals->xdb->query("SELECT nom, prenom, promo, user_id FROM auth_user_md5 AS u INNER JOIN aliases AS al ON (al.id = u.user_id AND al.type != 'liste') WHERE al.alias = {?}", $u); + + if (list($nom, $prenom, $promo, $uid) = $res->fetchOneRow()) + { + $res = $globals->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) + { + $page->trig_run("$prenom $nom est déjà membre du groupe !"); + } + elseif (Env::has('accept')) + { + $globals->xdb->execute("INSERT INTO groupex.membres VALUES ({?}, {?}, 'membre', 'X', NULL, NULL, NULL, NULL)", $globals->asso('id'), $uid); + require_once 'diogenes/diogenes.hermes.inc.php'; + $mailer = new HermesMailer(); + $mailer->addTo("$u@polytechnique.org"); + $mailer->setFrom('"'.Session::get('prenom').' '.Session::get('nom').'" <'.Session::get('forlife').'@polytechnique.org>'); + $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription'); + $message = "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 bien été validée !\n" + . "\n" + . "Bien cordialement,\n" + . "{$_SESSION["prenom"]} {$_SESSION["nom"]}."; + $mailer->setTxtBody($message); + $mailer->send(); + $page->kill("$prenom $nom a bien été inscrit"); + } + elseif (Env::has('refuse')) + { + require_once 'diogenes/diogenes.hermes.inc.php'; + $mailer = new HermesMailer(); + $mailer->addTo("$u@polytechnique.org"); + $mailer->setFrom('"'.Session::get('prenom').' '.Session::get('nom').'" <'.Session::get('forlife').'@polytechnique.org>'); + $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée'); + $mailer->setTxtBody(Env::get('motif')); + $mailer->send(); + $page->kill("la demande $prenom $nom a bien été refusée"); + } + else + { + $page->assign('show_form', true); + $page->gassign('prenom'); + $page->gassign('nom'); + $page->gassign('promo'); + $page->gassign('uid'); + } + } + else + { + $page->kill("utilisateur invalide"); + } +} elseif (is_member()) { + $page->kill("tu es déjà membre !"); +} elseif (Post::has('inscrire')) { + + $res = $globals->xdb->query('SELECT IF(m.email IS NULL, CONCAT(al.alias,"@polytechnique.org"), m.email) + FROM groupex.membres AS m + INNER JOIN aliases AS al ON (al.type = "a_vie" AND al.id = m.uid) + WHERE perms="admin" AND m.asso_id = {?}', $globals->asso('id')); + $emails = $res->fetchColumn(); + $to = implode(',', $emails); + + $append = "\n" + . "-- \n" + . "Ce message a été envoyé suite à la demande d'inscription de\n" + . Session::get('prenom').' '.Session::get('nom').' (X'.Session::get('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")."/inscrire.php?u=".Session::get('username')."\n" + . "\n" + . "En cas de problème, contacter l'équipe de Polytechnique.org\n" + . "à l'adresse : support@polytechnique.org\n"; + + require_once 'diogenes/diogenes.hermes.inc.php'; + $mailer = new HermesMailer(); + $mailer->addTo($to); + $mailer->setFrom('"'.Session::get('prenom').' '.Session::get('nom').'" <'.Session::get('forlife').'@polytechnique.org>'); + $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription'); + $mailer->setTxtBody(Post::get('message').$append); + $mailer->send(); +} + + +$page->run(); + +?> diff --git a/templates/xnet/groupe/inscrire.tpl b/templates/xnet/groupe/inscrire.tpl new file mode 100644 index 0000000..5fbe602 --- /dev/null +++ b/templates/xnet/groupe/inscrire.tpl @@ -0,0 +1,83 @@ +{*************************************************************************** + * Copyright (C) 2003-2004 Polytechnique.org * + * http://opensource.polytechnique.org/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + ***************************************************************************} + +

Demande d'inscription à {$asso.nom}

+ +{if $smarty.request.u && $admin && $show_form} + +

+ Demande de la part de : {$prenom} {$nom} (X{$promo}) + Voir sa fiche +

+
+ + +
+ ou bien +
+ + +
+
+ +{elseif $smarty.post.inscrire} + +

+Ta demande d'inscription a bien été envoyée ! Tu seras averti par email de la suite qui lui sera donnée. +

+

[Retour à la page d'accueil de {$asso.nom}]

+ +{else} + +

+Pour t'inscrire à {$asso.nom}, il te faut en demander l'autorisation aux animateurs du groupe via le +formulaire ci-dessous. Vérifie et corrige au besoin les différents champs, puis clique sur +"m'inscrire +

+
+

+ OUI, je souhaite être inscrit au groupe {$asso.nom} +

+

+ Indique ci-après tes motivations qui seront communiquées aux animateurs du groupe : +

+
+ +   + +
+
+ +{/if} + +{* vim:set et sw=2 sts=2 sws=2: *}