yet another x.net page !
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 21 Apr 2005 19:13:50 +0000 (19:13 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:43 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-587

htdocs.net/groupe/inscrire.php [new file with mode: 0644]
templates/xnet/groupe/inscrire.tpl [new file with mode: 0644]

diff --git a/htdocs.net/groupe/inscrire.php b/htdocs.net/groupe/inscrire.php
new file mode 100644 (file)
index 0000000..81f407f
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+require 'xnet.inc.php';
+
+new_page('xnet/groupe/inscrire.tpl', AUTH_PUBLIC);
+$page->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 (file)
index 0000000..5fbe602
--- /dev/null
@@ -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                *
+ ***************************************************************************}
+<h1>Demande d'inscription à {$asso.nom}</h1>
+
+{if $smarty.request.u && $admin && $show_form}
+
+<h2>
+  Demande de la part de : {$prenom} {$nom} (X{$promo})
+  <a href="https://www.polytechnique.org/fiche.php?user={$smarty.request.u}">Voir sa fiche</a>
+</h2>
+<form action="{$smarty.server.PHP_SELF}" method="post">
+  <input type="hidden" name="u" value="{$smarty.request.u}" />
+  <input type="submit" value="Accepter" name="accept" />
+  <br />
+  ou bien
+  <br />
+  <input type="submit" value="Refuser avec le motif ci-dessous" name="refuse" />
+  <textarea cols="70" rows="8" name="motif"></textarea>
+  <br />
+</form>
+
+{elseif $smarty.post.inscrire}
+
+<p class="descr">
+<strong>Ta demande d'inscription a bien été envoyée !</strong> Tu seras averti par email de la suite qui lui sera donnée.
+<p>
+<p class="descr">[<a href="asso.php">Retour à la page d'accueil de {$asso.nom}</a>]</p>
+
+{else}
+
+<p class="descr">
+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
+</p>
+<form action="{$smarty.server.PHP_SELF}" method="post">
+  <p class="descr">
+  <strong>OUI, je souhaite être inscrit au groupe {$asso.nom}</strong>
+  </p>
+  <p class="descr">
+  Indique ci-après <strong>tes motivations</strong> qui seront communiquées aux animateurs du groupe :
+  </p> <textarea cols=80 rows=12 name="message">
+Chers Camarades,
+
+Je souhaite m'inscrire à {$asso.nom}.
+
+Merci d'avance d'avoir la gentillesse de valider mon inscription.
+
+Bien cordialement,
+{$smarty.session.prenom} {$smarty.session.nom} (X{$smarty.session.promo})
+
+--
+Ma fiche sur Polytechnique.org :
+https://www.polytechnique.org/fiche.php?user={$smarty.session.forlife}
+</textarea>
+  <div class="center">
+    <input type="submit" name="inscrire" value="M'inscrire !" />
+    &nbsp;
+    <input type="reset" value="Annuler" />
+  </div>
+</form>
+
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2: *}