backport
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 2 May 2005 10:57:59 +0000 (10:57 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:51 +0000 (23:28 +0200)
Patches applied:

 * opensource@polytechnique.org--2005/platal--release--0.9.5--patch-12
   bugfix old alias homonym

 * opensource@polytechnique.org--2005/platal--release--0.9.5--patch-13
   obsolete

git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-619

include/identification.inc.php [deleted file]
include/register.inc.php
install.d/register/files

diff --git a/include/identification.inc.php b/include/identification.inc.php
deleted file mode 100644 (file)
index c3d7903..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-<?php
-/***************************************************************************
- *  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                *
- ***************************************************************************/
-
-require_once('xorg.misc.inc.php');
-
-function sortie_id($err) {
-    global $page;
-    new_skinned_page('inscription/step1.tpl', AUTH_PUBLIC);
-    $page->trig_run($err);
-}
-
-$promo = Env::getInt('promo');
-if ($promo<1900 || $promo>2100) {
-    sortie_id("La promotion doit comporter 4 chiffres.");
-}
-
-/* on recupere les donnees  */
-$prenom = preg_replace('/ +/',' ',trim(strip_request('prenom')));
-$nom    = preg_replace('/ +/',' ',trim(strip_request('nom')));
-
-// majuscules pour nom et prenom
-$nom    = strtoupper(replace_accent($nom));
-$prenom = make_firstname_case($prenom);
-
-// calcul du login
-$mailorg = make_username($prenom,$nom);
-$forlife = make_forlife($prenom,$nom,$promo);
-
-// version uppercase du prenom
-$prenomup=strtoupper(replace_accent($prenom));
-
-@list($chaine1,$chaine2) = preg_split("/[ \-']/",$nom);
-$chaine = strlen($chaine2) > strlen($chaine1) ? $chaine2 : $chaine1;
-
-// c'est parti pour l'identification, les champs étant corrects
-if ($promo > 1995)  {
-
-    if (strlen(Env::get('matricule')) != 6) {
-       sortie_id("Le matricule qu'il faut que tu  rentres doit comporter 6 chiffres.");
-    }
-
-    /* transformation du matricule afin de le rendre Y2K compliant
-     * (i.e. de la forme PPPP0XXX où PPPP est l'année d'inscription à l'école
-     * (i.e. le numéro de promotion sauf pour les étrangers voie 2) et XXX le numéro d'entrée cette année-là
-     */
-
-    $matrcondense  = Env::get('matricule');
-    $rangentree    = intval(substr($matrcondense, 3, 3));
-    $anneeimmatric = intval(substr($matrcondense, 0, 3));
-    if($anneeimmatric > 950) $anneeimmatric/=10;
-    if ($anneeimmatric < 96) {
-       sortie_id("ton matricule est incorrect");
-    } elseif ($anneeimmatric < 100) {
-       // jusqu'à la promo 99 c'est 9?0XXX
-       $year = 1900 + intval(substr($matrcondense, 0, 2));
-    }  elseif($anneeimmatric < 200) {
-       // depuis les 2000 c'est 10?XXX
-       $year = 2000 + intval(substr($matrcondense, 1, 2));
-    } else {
-       sortie_id("la gestion des promotions >= 2100 n'est pas prête !");
-    }
-
-    $matricule = sprintf('%04u%04u', $year, $rangentree);
-
-    // on vérifie que le matricule n'est pas déjà dans auth_user_md5
-    // sinon le même X pourrait s'inscrire deux fois avec le même matricule
-    // exemple yann.buril et yann.buril-dupont seraient acceptés ! alors que
-    // le matricule est unique
-    $res = $globals->xdb->query('SELECT user_id FROM auth_user_md5 WHERE matricule={?} AND perms IN("admin","user")', $matricule);
-    if ($res->numRows())  {
-       $str="Matricule déjà existant. Causes possibles\n"
-           ."- tu t'es trompé de matricule\n"
-           ."- tu t'es déjà inscrit une fois";
-       sortie_id($str);
-    }
-
-    // promotion jeune
-    $res = $globals->xdb->query('SELECT  nom, prenom FROM auth_user_md5
-                                  WHERE  matricule={?} AND promo={?} AND deces=0', $matricule, $promo);
-    list($mynom, $myprenom) = $res->fetchOneRow();
-    $mynomup      = strtoupper(replace_accent($mynom));
-    $myprenomup   = strtoupper(replace_accent($myprenom));
-    $autorisation = FALSE;
-
-    if (strlen($chaine2)>0)  {        // il existe au moins 2 chaines
-       // on teste l'inclusion des deux chaines
-       $autorisation = ( strstr($mynomup,$chaine1) && strstr($mynomup,$chaine2) && ($myprenomup == $prenomup) );
-    }  else   {
-       // la chaine2 est vide, on n'utilise que chaine
-       $autorisation = ( strstr($mynomup,$chaine) && ($myprenomup == $prenomup) );
-    }
-
-    if (!$autorisation) {
-       $str="Echec dans l'identification. Réessaie, il y a une erreur quelque part !";
-       sortie_id($str);
-    }
-
-} else {
-    // CODE SPECIAL POUR LES X DES PROMOTIONS AVANT 1996
-    $res = $globals->xdb->iterRow('SELECT nom,prenom,matricule FROM auth_user_md5 WHERE promo={?} AND deces=0', $promo);
-    $autorisation = false;
-    
-    if (strlen($chaine2)>0)  {        // il existe au moins 2 chaines
-       while (list($mynom,$myprenom,$mymat) = $res->next()) {
-           // verification de toute la promo !
-           $mynomup    = strtoupper(replace_accent($mynom));
-           $myprenomup = strtoupper(replace_accent($myprenom));
-
-           if ( strstr($mynomup,$chaine1) && strstr($mynomup,$chaine2) && ($myprenomup==$prenomup) )  {
-               $autorisation = true;
-               $matricule    = $mymat;
-               break;
-           }
-       }
-    } else {                       // une seule chaine
-
-       while (list($mynom,$myprenom,$mymat) = $res->next()) {
-           // verification de toute la promo !
-           $mynomup    = strtoupper(replace_accent($mynom));
-           $myprenomup = strtoupper(replace_accent($myprenom));
-           if ( strstr($mynomup,$chaine) && ($myprenomup==$prenomup) )  {
-               $autorisation = true;
-               $matricule    = $mymat;
-               break;
-           }
-       }
-    }
-
-    // on vérifie que le matricule n'est pas déjà dans auth_user_md5
-    // sinon le même X pourrait s'inscrire deux fois avec le même matricule
-    // exemple yann.buril et yan.buril seraient acceptés ! alors que le matricule
-    // est unique
-    if (! empty($matricule)) { 
-       $res = $globals->xdb->query('SELECT * FROM auth_user_md5 WHERE matricule={?} AND perms IN ("admin","user")', $matricule);
-       if ($res->numRows())  {
-           $str="Tu t'es déjà inscrit une fois.\n"
-               ."Ecris à <a href=\"mailto:support@polytechnique.org\">support@polytechnique.org</a> pour tout problème.";
-           sortie_id($str);
-       }
-    }
-
-    if (!$autorisation)  {
-       $str="Echec dans l'identification. Réessaie, il y a une erreur quelque part !";
-       sortie_id($str);
-    }
-    // identification < 1991 OK
-}
-
-/*****************************************************************************/
-/***************************** IDENTIFICATION OK *****************************/
-/*****************************************************************************/
-
-$res      = $globals->xdb->query('SELECT id,type,expire FROM aliases WHERE alias={?}', $mailorg);
-$homonyme = $res->numRows() > 0;
-
-if ( $homonyme ) {
-    $newbestalias = $mailorg . "." . sprintf("%02u",($promo%100));
-    
-    list($h_id, $h_type, $expire) = $res->fetchOneRow();
-
-    $res = $globals->xdb->query('SELECT alias FROM aliases WHERE alias={?}', $forlife);
-    if ( $res->numRows() > 0 ) {
-       sortie_id("Tu as un homonyme dans ta promo, il faut traiter ce cas manuellement.\n".
-               "envoie un mail à <a href=\"mailto:support@polytechnique.org\">support@polytechnique.org</a>");
-    }
-    $res->free();
-
-    if ( $h_type != 'homonyme' and empty($expire) ) {
-       $globals->xdb->execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg);
-       $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id);
-       require_once('diogenes/diogenes.hermes.inc.php');
-       $mailer = new HermesMailer();
-       $mailer->setFrom('"Support Polytechnique.org" <support@polytechnique.org>');
-       $mailer->addTo("$mailorg@polytechnique.org");
-       $mailer->setSubject("perte de ton alias $mailorg dans un mois !");
-       $mailer->addCc('"Support Polytechnique.org" <support@polytechnique.org>');
-       $msg =
-           "Un homonyme s'est inscrit, nous ne pouvons donc garder ton alias '$mailorg'.\n\n".
-           "Tu gardes tout de même l'usage de cet alias pour un mois encore à compter de ce jour.\n\n".
-           "Lorsque cet alias sera désactivé, l'adresse :\n".
-           "    $mailorg@polytechnique.org\n".
-           "renverra vers un robot qui indique qu'il y a plusieurs personnes portant le même nom ; cela évite que l'un des homonymes reçoive des courriels destinés à l'autre.\n\n".
-           "Pour te connecter au site, tu pourras utiliser comme identifiant : soit ton adresse à vie '$forlife', ".
-           "soit l'alias '$newbestalias'. Par ailleurs, commence dès aujourd'hui à communiquer à tes correspondants ".
-           "ton adresse :\n".
-           "    $newbestalias@polytechnique.org\n\n".
-           "En nous excusant pour le désagrément occasionné,\n".
-           "cordialement\n\n".
-           "-- \n".
-           "L'équipe de Polytechnique.org\n".
-           "\"Le portail des élèves & anciens élèves de l'X\"";
-       $mailer->SetTxtBody(wordwrap($msg,72));
-       $mailer->send();
-    }
-    $mailorg = $newbestalias;
-}
-
-?>
index 4b7bb6a..4bc0cfc 100644 (file)
@@ -192,7 +192,7 @@ function create_aliases (&$sub)
             $globals->xdb->execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg);
             $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id);
             $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $uid);
-            $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id={?}", $h_id);
+            $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id={?} AND expire IS NULL", $h_id);
             $als = $res->fetchColumn();
 
             require_once('diogenes/diogenes.hermes.inc.php');
index 886611a..91f201c 100644 (file)
@@ -1,6 +1,5 @@
 templates/admin/homonymes.tpl
 htdocs/admin/homonymes.php
-include/identification.inc.php
 htdocs/inscription/index.php
 htdocs/inscription/maj.php
 htdocs/inscription/step1.php