Merge branch 'master' of /home/git/platal into fusionax
authorPascal Corpet <pascal.corpet@m4x.org>
Fri, 11 Apr 2008 21:47:15 +0000 (23:47 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Fri, 11 Apr 2008 21:47:15 +0000 (23:47 +0200)
26 files changed:
bin/cron/checkdb.php
configs/.gitignore
htdocs/javascript/profile.js
htdocs/xorg.php
include/xorg/session.inc.php
modules/fusionax.php [new file with mode: 0644]
modules/fusionax/Activites.sql [new file with mode: 0644]
modules/fusionax/Adresses.sql [new file with mode: 0644]
modules/fusionax/Anciens.sql [new file with mode: 0644]
modules/fusionax/Entreprises.sql [new file with mode: 0644]
modules/fusionax/Formations.sql [new file with mode: 0644]
modules/fusionax/import-ax.sh [new file with mode: 0755]
modules/profile.php
modules/profile/general.inc.php
templates/events/index.tpl
templates/fusionax/ids.tpl [new file with mode: 0644]
templates/fusionax/idsMissingInAx.tpl [new file with mode: 0644]
templates/fusionax/idsMissingInXorg.tpl [new file with mode: 0644]
templates/fusionax/import.tpl [new file with mode: 0644]
templates/fusionax/index.tpl [new file with mode: 0644]
templates/fusionax/listFusion.tpl [new file with mode: 0644]
templates/fusionax/misc.tpl [new file with mode: 0644]
templates/profile/general.searchname.tpl [new file with mode: 0644]
templates/profile/general.tpl
upgrade/fusionax-0.0.1/00_names.sql [new file with mode: 0644]
upgrade/fusionax-0.0.1/update.sh [new file with mode: 0755]

index b891fec..f32ad00 100755 (executable)
@@ -175,7 +175,25 @@ check("SELECT  matricule,nom,prenom,matricule_ax,COUNT(matricule_ax) AS c
         WHERE  matricule_ax != '0'
         GROUP BY  matricule_ax
         having  c > 1", "à chaque personne de l'annuaire de l'AX (identification_ax) doit correspondre AU PLUS UNE personne de notre annuaire (auth_user_md5) -> si ce n'est pas le cas il faut regarder en manuel ce qui ne va pas !");
-
+        
+/* each alumni has one and only one display name by default and one and only one name when we talk to him directly */
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c
+        FROM `auth_user_md5` AS u
+        LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'default'))
+        GROUP BY u.`user_id`
+        HAVING c != 1", "chaque personne doit avoir un et un seul nom par défaut");
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c
+        FROM `auth_user_md5` AS u
+        LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'yourself'))
+        GROUP BY u.`user_id`
+        HAVING c != 1", "chaque personne doit avoir un et un seul nom quand on lui parle");
+
+/* no alumni is allowed to have empty names */
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`
+        FROM `auth_user_md5` AS u
+        INNER JOIN `profile_names_search` AS n USING(`user_id`)
+        WHERE n.`search_name` = ''", "liste des personnes qui ont un de leur nom de recherche vide");
+        
 /* verifie qu'il n'y a pas d'utilisateurs ayant un compte Google Apps désactivé et une redirection encore active vers Google Apps */
 check("SELECT  a.alias, g.g_status, u.mail_storage
          FROM  auth_user_md5 AS u
index 08b9b45..8767aa4 100644 (file)
@@ -1,3 +1,4 @@
 platal.conf
 platal.cron
+ax_xorg_rsa.pem
 *.pem
index 5c25580..fea3e4b 100644 (file)
@@ -88,7 +88,26 @@ function selectType(selectCtrl, type)
     }
 }
 
+function addSearchName()
+{
+  var i = 0;
+  while (document.getElementById('search_name_' + i) != null) {
+      i++;
+  }
+  $('#add_search_name').before('<div id="search_name_' + i + '" style="padding:2px" class="center"></div>');
+  Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i,function(){
+    $('#search_name_'+i+' input')[1].focus();
+  });
+}
 
+function removeSearchName(i)
+{
+  if (document.getElementById('search_name_'+i+'_new') != null) {
+    $('#search_name_'+i).remove();
+  } else {
+    removeObject('search_name_'+i, 'search_name['+i+']');
+  }
+}
 
 // Addresses
 
index 93226b9..396185f 100644 (file)
@@ -28,6 +28,7 @@ if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
                          'geoloc', 'lists', 'marketing', 'payment', 'platal',
                          'profile', 'register', 'search', 'stats', 'admin',
                          'newsletter', 'axletter', 'bandeau', 'survey',
+                         'fusionax',
                          'gadgets', 'googleapps');
     $platal->run();
 
index 62f5d30..70821f1 100644 (file)
@@ -239,15 +239,18 @@ function try_cookie()
 function start_connexion ($uid, $identified)
 {
     $res  = XDB::query("
-        SELECT  u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
+        SELECT  u.user_id AS uid, nom_usage, perms, promo, promo_sortie,
                 matricule, password, FIND_IN_SET('femme', u.flags) AS femme,
                 a.alias AS forlife, a2.alias AS bestalias,
                 q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
-                FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version
+                FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version,
+                nd.display AS display_name, nd.yourself AS yourself_name,
+                nd.first_name AS prenom, nd.last_name AS nom
           FROM  auth_user_md5   AS u
     INNER JOIN  auth_user_quick AS q  USING(user_id)
     INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
     INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
+    INNER JOIN  profile_names_display AS nd ON (u.user_id = nd.user_id)
          WHERE  u.user_id = {?} AND u.perms IN('admin','user')", $uid);
     $sess = $res->fetchOneAssoc();
     $res = XDB::query("SELECT  UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
diff --git a/modules/fusionax.php b/modules/fusionax.php
new file mode 100644 (file)
index 0000000..ff3e33d
--- /dev/null
@@ -0,0 +1,391 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2007 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                *
+ ***************************************************************************/
+
+/**
+ * @brief Module to merge data from AX database
+ *
+ * Module to import data from another database of alumni that had
+ * different schemas. The organization that used this db is called AX
+ * hence the name of this module.
+ *
+ * Datas are stored in an external server and you need a private key
+ * to connect to their server.
+ */
+class FusionAxModule extends PLModule{
+
+    /// path ok private key file to connect to AX server
+    var $ax_xorg_rsa_key;
+
+    function __construct()
+    {
+        $this->ax_xorg_rsa_key =
+            dirname(__FILE__).'/../configs/ax_xorg_rsa.pem';
+    }
+
+    function handlers()
+    {
+        return array(
+            'fusionax'          => $this->make_hook('index', AUTH_MDP, 'admin'),
+            'fusionax/import'   => $this->make_hook('import', AUTH_MDP,'admin'),
+            'fusionax/ids'      => $this->make_hook('ids', AUTH_MDP, 'admin'),
+            'fusionax/misc'     => $this->make_hook('misc', AUTH_MDP, 'admin'),
+        );
+    }
+
+
+    function handler_index(&$page)
+    {
+        global $globals;
+        $page->changeTpl('fusionax/index.tpl');
+        $page->assign('xorg_title','Polytechnique.org - Fusion des annuaires');
+        if (isset($globals->fusionax) && 
+            isset($globals->fusionax->LastUpdate)) {
+            $page->assign(
+                'lastimport', 
+                date("d-m-Y",$globals->fusionax->LastUpdate));
+        } 
+    }
+    
+    /** Import de l'annuaire de l'AX depuis l'export situé sur leur serveur */
+    function handler_import(&$page, $action = 'index', $fileSQL = '')
+    {
+        if ($action == 'index') {
+            $page->changeTpl('fusionax/import.tpl');
+            $page->addJsLink('jquery.js');
+            global $globals;
+            if (isset($globals->fusionax) &&
+                isset($globals->fusionax->LastUpdate)) {
+                $page->assign(
+                    'lastimport',
+                    "le ".date("d/m/Y à H:i",$globals->fusionax->LastUpdate));
+            }
+            if (!file_exists($this->ax_xorg_rsa_key)) {
+                $page->assign(
+                    'keymissing',
+                    $this->ax_xorg_rsa_key);
+            }
+            return;
+        }
+        
+        // toutes les actions sont faites en ajax en utilisant jquery
+        header("Content-type: text/javascript; charset=utf-8");
+        
+        // log des actions
+        $report = array();
+        
+        // création d'un fichier temporaire si nécessaire
+        if (Env::has('tmpdir')) {
+            $tmpdir = Env::v('tmpdir');
+        } else {
+            $tmpdir = tempnam('/tmp', 'fusionax');
+            unlink($tmpdir);
+            mkdir($tmpdir);
+            chmod($tmpdir, 0700);
+            // copie la clef d'authentification (paire de clef RSA dont la
+            // partie publique est sur polytechniciens.com)
+            if (!copy(
+                $this->ax_xorg_rsa_key,
+                $tmpdir.'/ax_xorg_rsa'))
+                $report[] = 'Impossible de copier la clef pour se logger '.
+                    'au serveur AX';
+            chmod($tmpdir.'/ax_xorg_rsa', 0600);
+        }
+        
+        $modulepath = realpath(dirname(__FILE__).'/fusionax/').'/';
+        $olddir = getcwd();
+        chdir($tmpdir);
+        
+        if ($action == 'launch') {
+            // lancement : connexion en ssh et récupération du fichier depuis
+            // polyechniciens.com, décompression de l'archive et séparation en
+            // fichiers par tables
+            exec($modulepath.'import-ax.sh', $report);
+            $report[] = utf8_decode('Récupération du fichier terminé.');
+            $report[] = 'Import dans la base en cours...';
+            $next = 'integrateSQL';
+        } else if ($action == 'integrateSQL') {
+            // intégration des données dans la base MySQL
+            // liste des fichiers sql à exécuter
+            $filesSQL = array(
+                'Activites.sql',
+                'Adresses.sql',
+                'Anciens.sql',
+                'Formations.sql',
+                'Entreprises.sql');
+            if ($fileSQL != '') {
+                // récupère le contenu du fichier sql
+                $queries = explode(';',file_get_contents($modulepath.$fileSQL));
+                foreach ($queries as $q) if (trim($q)) {
+                    // coupe le fichier en requêtes individuelles
+                    if (substr($q,0,2) == '--') {
+                        // affiche les commentaires dans le report
+                        $lines = explode("\n",$q);
+                        $l = $lines[0];
+                        $report[] = addslashes(utf8_decode($l));
+                    }
+                    // exécute la requête
+                    XDB::execute($q);
+                }
+                // trouve le prochain fichier à exécuter
+                $trans = array_flip($filesSQL);
+                $nextfile = $trans[$fileSQL] + 1;
+            } else {
+                $nextfile = 0;
+            }
+            if (!isset($filesSQL[$nextfile])) {
+                // tous les fichiers ont été exécutés, on passe à l'étape
+                // suivante
+                $next = 'clean';
+            } else {
+                // on passe au fichier suivant
+                $next = 'integrateSQL/'.$filesSQL[$nextfile];
+            }
+        } else if ($action == 'clean') {
+            // nettoyage du fichier temporaire
+            chdir($olddir);
+            exec("rm -rf $tmpdir", $report);
+            $report[] = 'Fin de l\'import';
+            global $globals;
+            // met à jour la date de dernier import
+            $globals->change_dynamic_config(
+                array('LastUpdate' => time()),
+                'FusionAx');
+        }
+        $tmpdir = getcwd();
+        chdir($olddir);
+        foreach($report as $t)
+            // affiche les lignes de report
+            echo "$('#fusionax_import').append('".utf8_encode($t)."<br/>');\n";
+        if (isset($next)) {
+            // lance le prochain script s'il y en a un
+            echo "$.getScript('fusionax/import/".$next."?tmpdir=".
+                urlencode($tmpdir)."');";
+        }
+        // exit pour ne pas afficher la page template par défaut
+        exit;
+    }
+    
+    /** Lier les identifiants d'un ancien dans les deux annuaires
+     * @param user_id identifiant dans l'annuaire X.org
+     * @param matricule_ax identifiant dans l'annuaire de l'AX
+     * @return 0 si la liaison a échoué, 1 sinon
+     */          
+    private static function link_by_ids($user_id, $matricule_ax)
+    {
+        if (!XDB::execute("
+        UPDATE fusionax_import AS i 
+            INNER JOIN fusionax_xorg_anciens AS u 
+            SET
+                u.matricule_ax = i.id_ancien,
+                i.user_id = u.user_id,
+                i.date_match_id = NOW()
+            WHERE
+            i.id_ancien = {?} AND u.user_id = {?} AND (
+                u.matricule_ax != {?} OR u.matricule_ax IS NULL OR
+                i.user_id != {?} OR i.user_id IS NULL)",
+            $matricule_ax,
+            $user_id,
+            $matricule_ax,
+            $user_id))
+        {
+            return 0;
+        }
+        return XDB::affectedRows() / 2;  
+    }
+    
+    /** Recherche automatique d'anciens à lier entre les deux annuaires
+     * @param limit nombre d'anciens à trouver au max
+     * @param sure si true, ne trouve que des anciens qui sont quasi sûrs
+     * @return un XOrgDBIterator sur les entrées avec display_name, promo,
+     * user_id, id_ancien et display_name_ax
+     */              
+    private static function find_easy_to_link($limit = 10, $sure = false)
+    {
+        $easy_to_link = XDB::iterator("
+        SELECT 
+            xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
+            CONCAT(ax.prenom,' ',ax.nom_complet,' (X ',ax.promotion_etude,')')
+                 AS display_name_ax,
+            COUNT(*) AS nbMatches
+        FROM fusionax_anciens AS ax
+        INNER JOIN fusionax_import AS i ON (
+            i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
+        LEFT JOIN fusionax_xorg_anciens AS xorg ON (
+            xorg.matricule_ax IS NULL AND 
+            ax.Nom_complet = xorg.nom AND
+            ax.prenom = xorg.prenom AND
+            xorg.promo = ax.promotion_etude)
+        GROUP BY xorg.user_id
+        HAVING
+            xorg.user_id IS NOT NULL AND
+            nbMatches = 1
+            ".($limit?('LIMIT '.$limit):''));
+        if ($easy_to_link->total() > 0 || $sure) {
+            return $easy_to_link;
+        }
+        return XDB::iterator(" 
+        SELECT 
+            xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
+            CONCAT(ax.prenom,' ',ax.nom_complet,' (X ',ax.promotion_etude,')')
+                 AS display_name_ax,
+            COUNT(*) AS nbMatches
+        FROM fusionax_anciens AS ax
+        INNER JOIN fusionax_import AS i ON (
+            i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
+        LEFT JOIN fusionax_xorg_anciens AS xorg ON (
+            xorg.matricule_ax IS NULL AND 
+            (ax.Nom_complet = xorg.nom
+                 OR ax.Nom_complet LIKE CONCAT(xorg.nom,' %')
+                 OR ax.Nom_complet LIKE CONCAT(xorg.nom,'-%')
+                 OR ax.Nom_usuel = xorg.nom
+                 OR xorg.nom LIKE CONCAT('% ',ax.Nom_complet)) AND
+            xorg.promo < ax.promotion_etude + 2 AND
+            xorg.promo > ax.promotion_etude - 2)
+        GROUP BY xorg.user_id
+        HAVING
+            xorg.user_id IS NOT NULL AND
+            nbMatches = 1
+        ".($limit?('LIMIT '.$limit):''));
+    }
+    
+    /** Module de mise en correspondance les ids */
+    function handler_ids(
+        &$page,
+        $part = 'main',
+        $user_id = null,
+        $matricule_ax = null)
+    {
+        global $globals;
+        $page->addJsLink('jquery.js');
+        
+        $page->assign(
+            'xorg_title',
+            'Polytechnique.org - Fusion - Mise en correspondance simple');
+        if ($part == 'missingInAX')
+        {
+            // locate all persons from this database that are not in AX's
+            $page->changeTpl('fusionax/idsMissingInAx.tpl');
+            $missingInAX = XDB::iterator("SELECT 
+                u.promo, u.user_id, u.display_name
+                FROM fusionax_xorg_anciens AS u
+                    WHERE u.matricule_ax IS NULL
+                    LIMIT 20");
+            $page->assign('missingInAX', $missingInAX);
+            return;
+        }
+        if ($part == 'missingInXorg')
+        {
+            // locate all persons from AX's database that are not here
+            $page->changeTpl('fusionax/idsMissingInXorg.tpl');
+            $missingInXorg = XDB::iterator("SELECT
+                a.promotion_etude AS promo,
+                CONCAT(a.prenom, ' ',a.Nom_usuel) AS display_name,
+                a.id_ancien 
+                FROM fusionax_import 
+                    INNER JOIN fusionax_anciens AS a USING (id_ancien)
+                    WHERE fusionax_import.user_id IS NULL
+                    LIMIT 20");
+            $page->assign('missingInXorg', $missingInXorg);
+            return;
+        }
+        if ($part == 'link')
+        {
+            FusionAxModule::link_by_ids($user_id,$matricule_ax);
+            exit;
+        }
+        if ($part == 'linknext')
+        {
+            $linksToDo = FusionAxModule::find_easy_to_link(10);
+            while ($l = $linksToDo->next())
+            {
+                FusionAxModule::link_by_ids($l['user_id'],$l['id_ancien']);
+            }
+            pl_redirect('fusionax/ids#autolink');
+        }
+        if ($part == 'linkall')
+        {
+            $linksToDo = FusionAxModule::find_easy_to_link(0);
+            while ($l = $linksToDo->next())
+            {
+                FusionAxModule::link_by_ids($l['user_id'],$l['id_ancien']);
+            }
+        }
+        {
+            $page->changeTpl('fusionax/ids.tpl');
+            $missingInAX = XDB::query(
+                'SELECT COUNT(*)
+                FROM fusionax_xorg_anciens AS u
+                WHERE u.matricule_ax IS NULL');
+            if ($missingInAX)
+            {
+                $page->assign('nbMissingInAX', $missingInAX->fetchOneCell());
+            }
+            $missingInXorg = XDB::query(
+                'SELECT COUNT(*)
+                FROM fusionax_import AS i
+                WHERE i.user_id IS NULL');
+            if ($missingInXorg)
+            {
+                $page->assign(
+                    'nbMissingInXorg',
+                    $missingInXorg->fetchOneCell());
+            }
+            $easyToLink = FusionAxModule::find_easy_to_link(10);
+            if ($easyToLink->total() > 0)
+            { 
+                $page->assign('easyToLink', $easyToLink);
+            }
+        }
+    }
+    
+    function handler_misc(&$page)
+    {
+        $page->changeTpl('fusionax/misc.tpl');
+        // deceased
+        $deceasedErrorsSql = XDB::query(
+            'SELECT COUNT(*) FROM fusionax_deceased');
+        $page->assign('deceasedErrors',$deceasedErrorsSql->fetchOneCell());
+        $page->assign('deceasedMissingInXorg',XDB::iterator(
+            'SELECT
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_ax,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
+            FROM fusionax_deceased AS d
+            WHERE d.deces_xorg = "0000-00-00"
+            LIMIT 10'));
+        $page->assign('deceasedMissingInAX',XDB::iterator(
+            'SELECT
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_xorg,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
+            FROM fusionax_deceased AD d
+            WHERE d.deces_ax = "0000-00-00"
+            LIMIT 10'));
+        $page->assign('deceasedDifferent',XDB::iterator(
+            'SELECT
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,
+                d.deces_ax,d.deces_xorg,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
+            FROM fusionax_deceased AS d
+            WHERE d.deces_xorg != "0000-00-00" AND d.deces_ax != "0000-00-00"
+            LIMIT 10'));
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:?>
diff --git a/modules/fusionax/Activites.sql b/modules/fusionax/Activites.sql
new file mode 100644 (file)
index 0000000..7db895a
--- /dev/null
@@ -0,0 +1,22 @@
+-- Import complet des activités professionnelles
+
+DROP TABLE IF EXISTS `fusionax_activites`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_activites` (
+  `AC` varbinary(2) NOT NULL COMMENT 'Vaut toujours AC pour cette table',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `hash_activite` binary(5) NOT NULL COMMENT 'Hash de cette ligne pour la lier à l''adresse',
+  `Code_etab` varbinary(10) NOT NULL COMMENT 'Code de l''établissement',
+  `Raison_sociale` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
+  `Libelle_fonctio` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'Libéllé de la fonction',
+  `Annuaire` BOOLEAN NOT NULL COMMENT 'publiable dans l''annuaire papier',
+  `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
+  PRIMARY KEY( `id_ancien` , `hash_activite` )
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Activites.txt' INTO TABLE `fusionax_activites` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(AC, id_ancien, Code_etab, Raison_sociale, Libelle_fonctio, Annuaire, 
+@Ligne1, @Ligne2, @Ligne3, @code_postal, @ville, @zip_cedex, @etat_distr, @pays, @tel, @fax, @StringDate_maj)
+SET 
+`hash_activite` = SUBSTRING( MD5( CONCAT(Code_etab, Libelle_fonctio) ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/Adresses.sql b/modules/fusionax/Adresses.sql
new file mode 100644 (file)
index 0000000..1b9ed47
--- /dev/null
@@ -0,0 +1,47 @@
+-- Import complet des adresses
+
+DROP TABLE IF EXISTS `fusionax_adresses`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_adresses` (
+  `provenance` varbinary(2) NOT NULL COMMENT 'Vaut AC, AD ou AN selon la provenance de l''info',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `Type_adr` enum('E', 'P') character set binary NOT NULL DEFAULT 'P' COMMENT 'Type d''adresse : E pour Entreprise, P pour Personnelle',
+  `hash_adresse` binary(5) NOT NULL COMMENT 'Hash pour différencier les diverses adresses',
+  `Ligne1` varchar(60) character set utf8 NOT NULL,
+  `Ligne2` varchar(60) character set utf8 NOT NULL,
+  `Ligne3` varchar(60) character set utf8 NOT NULL,
+  `code_postal` varchar(20) character set utf8 NOT NULL,
+  `ville` varchar(40) character set utf8 NOT NULL,
+  `zip_cedex` varchar(20) character set utf8 NOT NULL,
+  `etat_distr` varchar(20) character set utf8 NOT NULL,
+  `pays` varchar(50) character set utf8 NOT NULL,
+  `tel` varbinary(30) NOT NULL,
+  `fax` varbinary(30) NOT NULL,
+  `Date_maj` date NOT NULL,
+  PRIMARY KEY  (`id_ancien`, `hash_adresse`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Adresses.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(provenance, id_ancien, @Type_adr, Ligne1, Ligne2, Ligne3, code_postal, ville, zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
+SET 
+`Type_adr` = IF(@Type_adr = 'E', 'E', IF(@Type_adr = '', '', 'P')),
+`hash_adresse` = SUBSTRING( MD5( @Type_adr ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
+
+LOAD DATA LOCAL INFILE 'Anciens.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(provenance, id_ancien, @Login, @Password, @promotion_etude, @Groupe_promo, @Nom_patronymique, @partic_patro, @prenom, @Nom_usuel, @partic_nom,
+    @Nom_complet, @Civilite, @Code_nationalite, @Type_membre, @corps_sortie, @StringDate_deces, @grade, @Mel_usage, @Mel_publiable,
+    @tel_mobile, @annee_dernCot, @Representant, @Type_adr, Ligne1, Ligne2, Ligne3, code_postal, ville,
+    zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
+SET 
+`Type_adr` = IF(@Type_adr = 'E', 'E', IF(@Type_adr = '', '', 'P')),
+`hash_adresse` = SUBSTRING( MD5( @Type_adr ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
+
+LOAD DATA LOCAL INFILE 'Activites.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(provenance, id_ancien, @Code_etab, @Raison_sociale, @Libelle_fonctio, @Annuaire, 
+Ligne1, Ligne2, Ligne3, code_postal, ville, zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
+SET 
+`Type_adr` = 'E',
+`hash_adresse` = SUBSTRING( MD5( CONCAT(@Code_etab, @Libelle_fonctio) ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/Anciens.sql b/modules/fusionax/Anciens.sql
new file mode 100644 (file)
index 0000000..4aa07de
--- /dev/null
@@ -0,0 +1,64 @@
+-- Import complet des anciens
+
+DROP TABLE IF EXISTS `fusionax_anciens`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_anciens` (
+  `AN` varbinary(2) NOT NULL COMMENT 'Vaut toujours AN pour cette table',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `Login` varbinary(15) NOT NULL COMMENT 'Login sur le site de l''AX',
+  `Password` int(11) NOT NULL COMMENT 'Mot de passe sur le site AX',
+  `promotion_etude` int(11) NOT NULL COMMENT 'Promotion avec laquelle il/elle a fait ses études',
+  `Groupe_promo` enum('','A','B','C','N','S') character set binary NOT NULL COMMENT 'Groupe de promotion (code compris seulement par AX)',
+  `Nom_patronymique` varchar(50) character set utf8 NOT NULL COMMENT 'Nom patronymique (nom de jeune fille) sans la particule',
+  `partic_patro` varchar(5) character set utf8 NOT NULL COMMENT 'Particule du nom patronymique',
+  `prenom` varchar(30) character set utf8 NOT NULL COMMENT 'Prénom',
+  `Nom_usuel` varchar(50) character set utf8 NOT NULL COMMENT 'Nom usuel (nom marital par exemple) sans la particule',
+  `partic_nom` varchar(5) character set utf8 NOT NULL COMMENT 'Particule du nom usuel',
+  `Nom_complet` varchar(80) character set utf8 NOT NULL COMMENT 'Nom patronymique complet (avec la particule)',
+  `Civilite` enum('','.','M','MME','MLLE') character set utf8 NOT NULL COMMENT 'Civilité',
+  `Code_nationalite` varbinary(2) NOT NULL COMMENT 'Nationalité (code)',
+  `Type_membre` enum('','*','F','FB','P','PB','T','TB','TA') character set binary NOT NULL COMMENT 'Type de membre (code compris seulement par AX)',
+  `corps_sortie` varchar(10) character set utf8 NOT NULL COMMENT 'Corps de sortie (ou D si aucun)',
+  `Date_deces` DATE COMMENT 'Date de décès',
+  `grade` varbinary(20) NOT NULL COMMENT 'Grade actuel dans son corps',
+  `Mel_usage` varbinary(150) NOT NULL COMMENT 'Adresse e-mail d''usage',
+  `Mel_publiable` tinyint(4) NOT NULL COMMENT 'Autorisation d''utiliser le mail',
+  `tel_mobile` varbinary(30) NOT NULL COMMENT 'Numéro de téléphone mobile',
+  `annee_dernCot` int(11) NOT NULL COMMENT 'Année de dernière cotisation AX',
+  `Representant` enum('','K','DE') character set binary NOT NULL COMMENT 'Représentant de promotion',
+  `hash_adr_defaut` binary(5) NOT NULL COMMENT 'Hash de l''adresse par défaut',
+  `Date_maj` DATE NOT NULL,
+  PRIMARY KEY  (`id_ancien`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Anciens.txt' INTO TABLE `fusionax_anciens` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(`AN`, `id_ancien`, `Login`, `Password`, `promotion_etude`, `Groupe_promo`, `Nom_patronymique`, `partic_patro`, `prenom`, Nom_usuel, partic_nom,
+    Nom_complet, Civilite, Code_nationalite, Type_membre, corps_sortie, @StringDate_deces, grade, Mel_usage, Mel_publiable,
+    tel_mobile, annee_dernCot, Representant, @Type_adr_defaut, @AdrC_Ligne1, @AdrC_Ligne2, @AdrC_Ligne3, @AdrC_code_postal, @AdrC_ville,
+    @AdrC_zip_cedex, @AdrC_etat_distr, @AdrC_pays, @tel, @fax, @StringDate_maj)
+SET
+    `hash_adr_defaut` = SUBSTRING( MD5( @Type_adr_defaut ), 1, 5),
+    `Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2)),
+    `Date_deces` = CONCAT(SUBSTRING(@StringDate_deces,7),'-',SUBSTRING(@StringDate_deces,4,2),'-',SUBSTRING(@StringDate_deces,1,2));
+
+-- Correspondances entre fiches X.org et fiches AX
+DROP TABLE IF EXISTS `fusionax_import`;
+CREATE TABLE IF NOT EXISTS `fusionax_import` (
+  `id_ancien` binary(8) NOT NULL COMMENT 'identifiant AX de l''ancien',
+  `user_id` int(11) default NULL COMMENT 'identifiant x.org de l''ancien si on l''a trouvé',
+  `date_match_id` timestamp NULL default NULL COMMENT 'date de mise en correspondance des identifiants',
+  PRIMARY KEY  (`id_ancien`),
+  KEY `user_id` (`user_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+INSERT INTO `fusionax_import` ( SELECT `id_ancien`, NULL, NULL FROM `fusionax_anciens` );
+REPLACE INTO `fusionax_import` ( SELECT `matricule_ax`, `user_id`, NOW() FROM `auth_user_md5` );
+
+DROP VIEW IF EXISTS `fusionax_deceased`;
+
+CREATE VIEW `fusionax_deceased` AS 
+SELECT u.user_id, a.id_ancien, u.nom, u.prenom, u.promo, u.deces AS deces_xorg, a.Date_deces AS deces_ax
+FROM `auth_user_md5` AS u
+INNER JOIN fusionax_anciens AS a ON ( a.id_ancien = u.matricule_ax )
+WHERE u.deces != a.Date_deces;
diff --git a/modules/fusionax/Entreprises.sql b/modules/fusionax/Entreprises.sql
new file mode 100644 (file)
index 0000000..651d24b
--- /dev/null
@@ -0,0 +1,17 @@
+-- Import complet des entreprises
+
+DROP TABLE IF EXISTS `fusionax_entreprises`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_entreprises` (
+  `EN` varbinary(2) NOT NULL COMMENT 'Vaut toujours EN pour cette table',
+  `Code_etab` varbinary(10) NOT NULL COMMENT 'Code de l''établissement',
+  `Raison_sociale` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
+  `Sigle` varchar(50) collate utf8_unicode_ci NOT NULL COMMENT 'Sigle de l''établissement',
+  `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
+  PRIMARY KEY(`Code_etab`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Entreprises.txt' INTO TABLE `fusionax_entreprises` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(EN, Code_etab, Raison_sociale, Sigle, @Inconnu, @StringDate_maj)
+SET 
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/Formations.sql b/modules/fusionax/Formations.sql
new file mode 100644 (file)
index 0000000..7d2854a
--- /dev/null
@@ -0,0 +1,16 @@
+-- Import complet des formations
+
+DROP TABLE IF EXISTS `fusionax_formations`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_formations` (
+  `FO` varbinary(2) NOT NULL COMMENT 'Vaut toujours FO pour cette table',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `Intitule_formation` varchar(60) collate utf8_unicode_ci NOT NULL COMMENT 'Intitulé de la formation',
+  `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
+  PRIMARY KEY (`id_ancien`, `Intitule_formation`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Formations.txt' INTO TABLE `fusionax_formations` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(FO, id_ancien, Intitule_formation, @StringDate_maj)
+SET 
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/import-ax.sh b/modules/fusionax/import-ax.sh
new file mode 100755 (executable)
index 0000000..35b4b6a
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/bash
+
+# import des données
+scp -i ax_xorg_rsa xorg@polytechniciens.com:/home/axasso/ax-import/export_4D.txt.rar .
+unrar e -inul export_4D.txt.rar
+
+# séparation en fichiers de tables 
+cat export-total* | grep ^AD > Adresses.txt
+cat export-total* | grep ^AN > Anciens.txt
+cat export-total* | grep ^FO > Formations.txt
+cat export-total* | grep ^AC > Activites.txt
+cat export-total* | grep ^EN > Entreprises.txt
+
+exit 1
+
+# intégration dans notre bdd
+echo intégration dans notre bdd
+$MYSQL x4dat < Activites.sql
+$MYSQL x4dat < Adresses.sql
+$MYSQL x4dat < Anciens.sql
+$MYSQL x4dat < Formations.sql
+$MYSQL x4dat < Entreprises.sql
+
+# nettoyage
+echo nettoyage
+rm Adresses.txt Anciens.txt Formations.txt Activites.txt Entreprises.txt export_4D.txt.rar export-total*
index bde1cf2..824de3e 100644 (file)
@@ -38,6 +38,7 @@ class ProfileModule extends PLModule
             'profile/ajax/job'     => $this->make_hook('ajax_job',     AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/skill'   => $this->make_hook('ajax_skill',   AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/searchname'   => $this->make_hook('ajax_searchname',   AUTH_COOKIE, 'user', NO_AUTH),
             'javascript/applis.js' => $this->make_hook('applis_js', AUTH_COOKIE),
             'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE),
             'profile/medal'    => $this->make_hook('medal', AUTH_PUBLIC),
@@ -434,6 +435,15 @@ class ProfileModule extends PLModule
         }
     }
 
+    function handler_ajax_searchname(&$page, $snid)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $page->changeTpl('profile/general.searchname.tpl', NO_SKIN);
+        $page->assign('i', $snid);
+        $page->assign('sn', array());
+        $page->assign('newsn', true);
+    }
+    
     function handler_p_orange(&$page)
     {
         $page->changeTpl('profile/orange.tpl');
index ac81f59..d6ffdaa 100644 (file)
@@ -65,6 +65,22 @@ class ProfileNom implements ProfileSetting
     }
 }
 
+class ProfileSearchName implements ProfileSetting
+{
+
+    public function __construct()
+    {
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+    }
+
+    public function save(ProfilePage &$page, $field, $new_value)
+    {
+    }
+}
+
 class ProfileAppli implements ProfileSetting
 {
     public function value(ProfilePage &$page, $field, $value, &$success)
@@ -109,6 +125,10 @@ class ProfileGeneral extends ProfilePage
         $this->settings['freetext']
                                   = $this->settings['nationalite']
                                   = $this->settings['nick']
+                                  = $this->settings['yourself']
+                                  = $this->settings['display_name']
+                                  = $this->settings['sort_name']
+                                  = $this->settings['tooltip_name']
                                   = null;
         $this->settings['synchro_ax']
                                   = new ProfileBool();
@@ -130,9 +150,12 @@ class ProfileGeneral extends ProfilePage
                                    q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub,
                                    q.profile_nick as nick, q.profile_from_ax as synchro_ax, u.matricule_ax,
                                    IF(a1.aid IS NULL, -1, a1.aid) as appli_id1, a1.type as appli_type1,
-                                   IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2
+                                   IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2,
+                                   n.yourself, n.display AS display_name, n.sort AS sort_name,
+                                   n.tooltip AS tooltip_name
                              FROM  auth_user_md5   AS u
-                       INNER JOIN  auth_user_quick AS q  USING(user_id)
+                       INNER JOIN  auth_user_quick AS q  ON(u.user_id = q.user_id)
+                       INNER JOIN  profile_names_display AS n ON(n.user_id = u.user_id)
                         LEFT JOIN  applis_ins      AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)
                         LEFT JOIN  applis_ins      AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)
                             WHERE  u.user_id = {?}", S::v('uid', -1));
@@ -159,6 +182,14 @@ class ProfileGeneral extends ProfilePage
                             WHERE  type='photo' AND user_id = {?}",
                           S::v('uid'));
         $this->values['nouvellephoto'] = $res->fetchOneCell();
+        
+        // Retreive search names info
+        $this->values['search_names'] = XDB::iterator("
+                              SELECT sn.search_name, sn.name_type, sn.pub, sn.sn_id
+                                FROM profile_names_search AS sn
+                               WHERE sn.user_id = {?}
+                            ORDER BY sn.name_type, search_score, search_name",
+                          S::v('uid'));
     }
 
     protected function _saveData()
@@ -195,6 +226,20 @@ class ProfileGeneral extends ProfilePage
                            WHERE  uid = {?}",
                          $this->values['photo_pub'], S::v('uid'));
         }
+        if ($this->changed['yourself'] || $this->changed['sort_name'] ||
+            $this-> changed['display_name'] || $this->changed['tooltip_name']) {
+          XDB::execute("UPDATE profile_names_display AS n
+                           SET n.yourself = {?},
+                               n.sort = {?}, ". // SET
+                              "n.display = {?}, ". // SET
+                              "n.tooltip = {?} ". // SET
+                        "WHERE n.user_id = {?}",
+                       $this->values['yourself'],
+                       $this->values['sort_name'],
+                       $this->values['display_name'],
+                       $this->values['tooltip_name'],
+                        S::v('uid'));
+        }
     }
 
     public function _prepare(PlatalPage &$page, $id)
index 9ecbe18..3f63968 100644 (file)
@@ -27,7 +27,7 @@
 {else}
 
 <h1 id='pagetop'>
-Bienvenue {$smarty.session.prenom}{if $birthday}
+Bienvenue {$smarty.session.yourself_name}{if $birthday}
   &nbsp;et joyeux anniversaire de la part de toute l'équipe !
 {else},
 {/if}
diff --git a/templates/fusionax/ids.tpl b/templates/fusionax/ids.tpl
new file mode 100644 (file)
index 0000000..fb6df30
--- /dev/null
@@ -0,0 +1,77 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / Identifiants</h2>
+
+<p>Le préalable à toute fusion de renseignements pour une personne entre ce
+que contient la base AX et ce que contient ce site est bien évidemment de
+trouver une correspondance entre les personnes renseignés dans ces annuaires.</p>
+
+{if $nbMissingInAX}
+<h3>Anciens manquants à l'AX</h3>
+
+<p><a href="fusionax/ids/missingInAX">{$nbMissingInAX} ancien{if $nbMissingInAX > 1}s{/if}</a>.</p>
+{/if}
+
+{if $nbMissingInXorg > 0}
+<h3>Anciens manquants à x.org</h3>
+
+<p><a href="fusionax/ids/missingInXorg">{$nbMissingInXorg} ancien{if $nbMissingInXorg > 1}s{/if}</a>.</p>
+{/if}
+
+<h3>Mettre en correspondance</h3>
+<form action="fusionax/ids/lier" method="get">
+       Matricule AX : <input name="matricule_ax" value""/><br/>
+       User ID X.org : <input name="user_id" value=""/><br/>
+       <input type="submit" value="Lier"/>
+</form>
+
+<p></p>
+<div id="autolink" name="autolink">
+<h3>Mise en correspondance automatique</h3>
+{if $easyToLink}
+<p>Ces anciens sont probablement les mêmes (à peu près mêmes nom, prénom, promo)</p>
+{include file="fusionax/listFusion.tpl" fusionList=$easyToLink fusionAction="fusionax/ids/link" name="lier" field1="display_name_ax" namefield1="Ancien AX"}
+<p><a href="fusionax/ids/linknext">Lier toutes les fiches affichées</a> <span id="fusion-reload" style="display:none"> - <a href="fusionax/ids#autolink">Trouver d'autres correspondances</a></span></p>
+<script type="text/javascript">
+{literal}
+//<!--
+$(document).ready(function() {
+    $('#autolink a.fusion-action').click(function(a){
+        $.get(a.currentTarget.href,{},function(){
+            $(a.currentTarget).hide();
+            $('#fusion-reload').show();
+            $('#fusion-reload a').click(function(a) {
+                document.location = a.currentTarget.href;
+                document.location.reload();
+            }); 
+        });
+        return false;
+    });
+});
+//-->
+{/literal}
+</script>
+{else}
+<p>Aucune correspondance automatique n'a été trouvée (mêmes nom, prénom, promo d'étude).</p>
+{/if}
+</div>
diff --git a/templates/fusionax/idsMissingInAx.tpl b/templates/fusionax/idsMissingInAx.tpl
new file mode 100644 (file)
index 0000000..8d5ba8c
--- /dev/null
@@ -0,0 +1,29 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / <a href="fusionax/ids">Identifiants<a> /  Manquants dans l'annuaire de l'AX</h2>
+
+<p></p>
+
+{if $missingInAX}
+{include file='fusionax/listFusion.tpl' fusionList=$missingInAX field1='user_id' namefield1='ID X.org'}
+{/if}
diff --git a/templates/fusionax/idsMissingInXorg.tpl b/templates/fusionax/idsMissingInXorg.tpl
new file mode 100644 (file)
index 0000000..036d6d4
--- /dev/null
@@ -0,0 +1,29 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / <a href="fusionax/ids">Identifiants<a> /  Manquants dans l'annuaire d'X.org</h2>
+
+<p></p>
+
+{if $missingInXorg}
+{include file='fusionax/listFusion.tpl' fusionList=$missingInXorg field1='id_ancien' namefield1='matricule AX'}
+{/if}
diff --git a/templates/fusionax/import.tpl b/templates/fusionax/import.tpl
new file mode 100644 (file)
index 0000000..7982e3d
--- /dev/null
@@ -0,0 +1,50 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<script type="text/javascript">
+{literal}
+//<!--
+    $(document).ready(function() {
+        $('#fusionax_import input').click(function() {
+            $('#fusionax_import input').hide();
+            $('#fusionax_import').append('Import en cours : récupération du fichier depuis le serveur de l\'AX...<br/>');
+            $.getScript('fusionax/import/launch');
+        });
+    });
+//-->
+{/literal}
+</script> 
+<h2><a href="fusionax">Fusion des annuaires X.org - AX</a></h2>
+
+<h2>Import de l'annuaire AX</h2>
+{if $lastimport}
+<p>Dernier import {$lastimport}</p>
+{/if}
+
+{if $keymissing}
+<p>Impossible de faire l'import, il manque la clef d'authentification :</p>
+<pre>{$keymissing}</pre>
+{else}
+<div id="fusionax_import">
+<input type="button" value="Lancer l'import"/>
+</div>
+{/if}
diff --git a/templates/fusionax/index.tpl b/templates/fusionax/index.tpl
new file mode 100644 (file)
index 0000000..ec652b4
--- /dev/null
@@ -0,0 +1,35 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2>Fusion des annuaires X.org - AX</h2>
+<ul>
+<li>Voir la <a href="Fusion">documentation</a></li>
+<li><a href="fusionax/import">Import de la base AX</a> {if $lastimport} - (dernier import le {$lastimport}){/if}</li> 
+<li>Mise en <a href="fusionax/ids">correspondance simple</a></li>
+<li>Corrélation des <a href="fusionax/names">données d'identification</a></li>
+<li>Corrélation des <a href="fusionax/coords">coordonnées</a></li>
+<li>Corrélation des <a href="fusionax/pros">informations professionnelles</a></li>
+<li>Corrélation des <a href="fusionax/studies">informations de formations</a></li>
+<li><a href="fusionax/misc">Divers</a></li>
+</ul>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/fusionax/listFusion.tpl b/templates/fusionax/listFusion.tpl
new file mode 100644 (file)
index 0000000..cd362f6
--- /dev/null
@@ -0,0 +1,57 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<table class="bicol">
+    <tr>
+        <th>Ancien</th>
+        <th>Fiches</th>
+        {if $field1}
+        <th>{$namefield1}</th>
+        {/if}
+        {if $field2}
+        <th>{$namefield2}</th>
+        {/if}
+        {if $fusionAction}
+        <th>Action</th>
+        {/if}
+    </tr>
+{if $fusionList}
+{iterate from=$fusionList item=c}
+    <tr class="{cycle values="pair,impair"}">
+        <td>{$c.display_name} (X {$c.promo})</td>
+        <td style="text-align:center">
+            {if $c.user_id}<a href="admin/user/{$c.user_id}" class="popup2">{icon name="user_suit" title="Administrer utilisateur"}</a>{/if}
+            {if $c.id_ancien}<a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$c.id_ancien}" class="popup2">{icon name="user_gray" title="fiche AX"}</a>{/if}
+        </td>
+        {if $field1}
+        <td>{$c.$field1}</td>
+        {/if}
+        {if $field2}
+        <td>{$c.$field2}</td>
+        {/if}
+        {if $fusionAction}
+        <td><a class="fusion-action" href="{$fusionAction}/{$c.user_id}/{$c.id_ancien}">{$name}</a></td>
+        {/if}
+    </tr>
+{/iterate}
+{/if}
+</table>
diff --git a/templates/fusionax/misc.tpl b/templates/fusionax/misc.tpl
new file mode 100644 (file)
index 0000000..de6b539
--- /dev/null
@@ -0,0 +1,48 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / Divers</h2>
+
+<h3>Décès</h3>
+
+{if $deceasedErrors}
+
+<p>Voici les {$deceasedErrors} différences entre les deux annuaires pour les renseignements de
+décès.</p>
+
+<p>Anciens déclarés décédés dans l'annuaire AX mais pas sur Xorg</p>
+
+{include file='fusionax/listFusion.tpl' fusionList=$deceasedMissingInXorg field1='deces_ax' namefield1='Décès AX'}
+
+<p>Anciens déclarés décédés dans l'annuaire Xorg mais pas chez l'AX</p>
+
+{include file='fusionax/listFusion.tpl' fusionList=$deceasedMissingInAX field1='deces_xorg' namefield1='Décès X.org'}
+
+<p>Anciens déclarés décédés dans les deux annuaires mais pas avec la même date</p>
+
+{include file='fusionax/listFusion.tpl' fusionList=$deceasedDifferent field1='deces_xorg' field2='deces_ax' namefield1='Décès X.org' namefield2='Décès AX'}
+
+{else}
+
+<p>Aucune différence pour les renseignements de décès entre les deux annuaires.</p>
+
+{/if}
diff --git a/templates/profile/general.searchname.tpl b/templates/profile/general.searchname.tpl
new file mode 100644 (file)
index 0000000..085915d
--- /dev/null
@@ -0,0 +1,46 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<span class="flags">
+    <input type="checkbox"
+        {if $sn.pub neq 'private'} checked="checked"{/if}
+        {if $sn.pub eq 'always public'} disabled="disabled"{else} name="search_name[{$i}][pub]"{/if}/>
+    {icon name="flag_green" title="site public"}
+</span>&nbsp;
+<input type="text" name="search_name[{$i}][name]" value="{$sn.search_name}" size="30"/>
+<select name="search_name[{$i}][type]">
+  <option value="firstname"{if $sn.name_type eq 'firstname'} selected="selected"{/if}>Prénom</option>
+  <option value="lastname"{if $sn.name_type eq 'lastname'} selected="selected"{/if}>Nom de famille</option>
+  <option value="surname"{if $sn.name_type eq 'surname'} selected="selected"{/if}>Surnom</option>
+</select>
+{if $sn.pub neq 'always public'}
+  <a href="javascript:removeSearchName({$i})">
+    {icon name=cross title="Supprimer ce nom de recherche"}
+  </a>
+  {if $newsn}
+    <span style="display:none" id="search_name_{$i}_new">Nouveau</span>
+  {else}
+    <input type="hidden" name="search_name[{$i}][removed]" value=""/>
+  {/if}
+{else}
+    {icon name="null"}
+{/if}
index ebde068..432ed10 100644 (file)
   </tr>
   <tr>
     <td>
-      <span class="titre">Nom</span>
-      <span class="comm"></span>
+      <span class="titre">Nom</span><br/>
     </td>
     <td>
-      <input type='text' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
+      {$nom}
+      <input type='hidden' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
     </td>
   </tr>
   <tr>
     <td>
-      <span class="titre">Prénom</span>
-      <span class="comm"></span>
+      <span class="titre">Prénom</span><br/>
     </td>
     <td>
-      <input type='text' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
+      {$prenom}
+      <input type='hidden' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
     </td>
   </tr>
   <tr>
     <td>
-      <span class="titre">Promotion</span>
+      <span class="titre">Affichage de ton nom</span>
     </td>
     <td>
-      <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
-      <span class="lien"><a href="profile/orange">modifier</a>{if ($promo_sortie -3 == $promo)} pour les oranges{/if}</span>
+      {if $tooltip_name}<span title="{$tooltip_name}" style="border-bottom: 1px dashed black;">{$display_name}</span>{else}{$display_name}{/if}
+      <a href="profile/edit#names_advanced" onclick="$('#names_advanced').show('normal', {literal}function(){document.location = document.location + '#names_advanced';}{/literal});return false">
+        {icon name="page_edit" title="Plus de détail"}
+      </a>
     </td>
   </tr>
   <tr>
     <td>
-      <span class="titre">Nom d'usage</span><br />
-      {if $smarty.session.sexe}
-      <span class="comm">(Notamment nom d'épouse)</span>
-      {else}
-      <span class="comm">(si différent de {$nom} seulement)</span>
-      {/if}
+      <span class="titre">Promotion</span>
     </td>
     <td>
-      <span class="nom">{$nom_usage|default:"Aucun"}</span>
-      <span class="lien"><a href="profile/usage">modifier</a></span>
+      <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
+      <span class="lien"><a href="profile/orange" {if ($promo_sortie -3 == $promo)} {popup text="pour les oranges"}{/if}>{icon name="page_edit" title="modifier"}</a></span>
     </td>
   </tr>
   <tr>
   </tr>
 </table>
 
+<table class="bicol" style="margin-bottom: 1em;display:none"
+  summary="Profil : Noms" id="names_advanced">
+  <tr>
+    <th colspan="2">
+      Noms
+    </th>
+  </tr>
+  <tr class="impair" {popup caption="Affichage courant de ton nom" text="Ceci
+est le nom qui s'affichera partout sur le site quand ton nom est mentionné dans
+une liste, en haut de ta fiche ou lorsque tu proposes une annonce. On utilise
+généralement le prénom usuel suivi du nom usuel avec des majuscules seulement
+pour les premières lettres : <strong>Alfred&nbsp;de&nbsp;Musset</strong>" width="400"}>
+    <td>
+      <span class="flags">
+        <input type="checkbox" checked="checked" disabled="disabled" />
+        {icon name="flag_green" title="site public"}
+      </span>&nbsp;
+      <span class="titre">Affichage courant de ton nom</span>
+    </td>
+    <td>
+      <input type="text" name="display_name" value="{$display_name}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair" {popup caption="Explication du nom" text="Tu peux rajouter une
+  brêve explication de ton nom si par exemple il arrive qu'on confonde ton prénom
+  et ton nom, ou bien que vous êtes deux de la même promo à porter le même nom.
+  <strong>Prénom&nbsp;:&nbsp;Martin&nbsp;-&nbsp;Nom&nbsp;:&nbsp;Bernard</strong>" width="400"}>
+    <td>
+      <span class="titre">explication</span>
+    </td>
+    <td>
+      <input type="text" name="tooltip_name" value="{$tooltip_name}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair" {popup caption="Rangement du nom" text="Dans une liste d'anciens
+ ton nom sera rangé selon l'ordre alphabétique grâce à ce champs. On utilise
+ généralement le nom (sans particule) suivi d'une virgule et du prénom : <strong>
+ Dupont,&nbsp;Georges</strong>" width="400"}>
+    <td>
+      <span class="titre">ranger ce nom à</span>
+    </td>
+    <td>
+      <input type="text" name="sort_name" value="{$sort_name}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair" {popup caption="Comment doit-on t'appeler ?" text="Lorsque
+  nous t'envoyons un e-mail, nous nous adressons à toi par ton prénom. Le champs
+  suivant permet de changer cela. C'est surtout utile lorsque les e-mails sont
+  envoyés à une tierce personne (veuf ou veuve par exemple)" width="400"}>
+    <td>
+      <span class="flags">
+        <input type="checkbox" checked="checked" disabled="disabled" />
+        {icon name="flag_red" title="privé"}
+      </span>&nbsp;
+      <span class="titre">Comment on doit t'appeller</span>
+      <div class="smaller">dans les mails que nous t'envoyons</div>
+    </td>
+    <td>
+      <input type="text" name="yourself" value="{$yourself}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair" {popup caption="Noms de recherche" text="Tu peux ajouter ici
+  des noms pour apparaître dans les recherches. Tu peux par exemple ajouter le
+  nom que tu portais à l'école si tu as changé depuis ou bien un nom de scène, un
+  surnom ou encore le nom de ton conjoint. Les recherches ne fonctionneront que
+  sur la partie privée du site sauf si tu coches la case verte." width="400"}>
+    <td colspan="2">
+      <span class="titre">Recherche</span>
+      <span class="smaller">, ta fiche apparaît quand on cherche un de ces noms</span>
+      {iterate from=$search_names item="sn"}
+      <div id="search_name_{$sn.sn_id}" style="padding:2px" class="center">
+        {include file="profile/general.searchname.tpl" i=$sn.sn_id sn=$sn}
+      </div>
+      {/iterate}
+      <div id="add_search_name" class="center" style="clear: both">
+        <a href="javascript:addSearchName()">
+          {icon name=add title="Ajouter un nom de recherche"} Ajouter un nom
+        </a>
+      </div>
+    </td>
+</table>
+
 {if !$no_private_key}
 <table class="bicol"  style="margin-bottom: 1em"
   summary="Profil&nbsp;: Informations générales">
   </tr>
   <tr>
     <td>
-      <span class="flags">
-        <input type="checkbox" checked="checked" disabled="disabled" />
-        {icon name="flag_red" title="privé"}
-      </span>&nbsp;
-      <span class="titre">Surnom</span>
-    </td>
-    <td>
-      <input type="text" size="35" maxlength="64"
-             {if $errors.nick}class="error"{/if} name="nick" value="{$nick}" />
-    </td>
-  </tr>
-  <tr>
-    <td>
       <span class="titre">Téléphone mobile</span>
     </td>
     <td>
diff --git a/upgrade/fusionax-0.0.1/00_names.sql b/upgrade/fusionax-0.0.1/00_names.sql
new file mode 100644 (file)
index 0000000..e615bfd
--- /dev/null
@@ -0,0 +1,53 @@
+CREATE TABLE IF NOT EXISTS `profile_names_display` (
+  `user_id` int(11) NOT NULL COMMENT 'id of alumni',
+  `display` varchar(100) NOT NULL COMMENT 'name to display',
+  `sort` varchar(100) NOT NULL COMMENT 'name used for sorting',
+  `tooltip` varchar(150) NOT NULL COMMENT 'text to explain display name if needed',
+  `firstname` varchar(50) NOT NULL COMMENT 'first name',
+  `lastname` varchar(50) NOT NULL COMMENT 'last name',
+  `yourself` varchar(100) NOT NULL COMMENT 'name we used to speak to him/her',
+  PRIMARY KEY  (`user_id`),
+  KEY `sort` (`sort`)
+) CHARSET=utf8 COMMENT='Alumnis'' names to display';
+
+INSERT INTO `profile_names_display` (
+    SELECT 
+        `user_id`, 
+        CONCAT(`prenom`, ' ',IF(`nom_usage` != '',CONCAT(`nom_usage`,' (',`nom`,')'),`nom`)), 
+        CONCAT(IF(`nom_usage` != '',`nom_usage`,`nom`),', ',`prenom`),
+        '',
+        `prenom`,
+        IF(`nom_usage` != '',`nom_usage`,`nom`),
+        `prenom`
+        FROM `auth_user_md5`);
+        
+UPDATE `profile_names_display` AS n INNER JOIN `auth_user_md5` AS u ON n.lastname = u.prenom
+SET n.tooltip = CONCAT('Prénom : ', n.firstname,' - Nom : ', n.lastname);
+
+CREATE TABLE IF NOT EXISTS `profile_names_search` (
+  `user_id` int(11) NOT NULL COMMENT 'id of alumni',
+  `sn_id` smallint(6) NOT NULL COMMENT 'id of this search name in all alumni''s search names',
+  `search_name` varchar(50) NOT NULL COMMENT 'name to search for',
+  `name_type` enum('firstname','lastname','surname') NOT NULL default 'lastname' COMMENT 'type of name',
+  `search_score` smallint(6) NOT NULL COMMENT 'used to sort search results',
+  `pub` enum('always public','public','private') NOT NULL default 'private' COMMENT 'searchable on public site or only on private',
+  PRIMARY KEY  (`name_type`,`search_name`,`user_id`),
+  KEY `user_id` (`user_id`)
+) CHARSET=utf8 COMMENT='Names of alumni (search table)';
+
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 0, `nom`, 'lastname', 10, 'always public' FROM `auth_user_md5` WHERE `nom` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 1, `nom_usage`, 'lastname', 10, 'public' FROM `auth_user_md5` WHERE `nom` != `nom_usage` AND `nom_usage` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 2, `nom_ini`, 'lastname', 7, 'private' FROM `auth_user_md5` WHERE `nom` != `nom_ini` AND `nom_ini` != '' AND `nom_ini` != `nom_usage`);
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 3, `prenom`, 'firstname', 8, 'always public' FROM `auth_user_md5` WHERE `prenom` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 4, `prenom_ini`, 'firstname', 5, 'private' FROM `auth_user_md5` WHERE `prenom_ini` != `prenom` AND `prenom_ini` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 5, `profile_nick`, 'surname', 7, 'private' FROM `auth_user_quick` WHERE `profile_nick` != '');
+
+CREATE OR REPLACE ALGORITHM=MERGE VIEW fusionax_xorg_anciens AS 
+    SELECT
+        u.user_id, u.matricule_ax, u.promo,
+        n.display AS display_name, n.sort AS sort_name,
+        u.nom, u.prenom
+    FROM `auth_user_md5` AS u
+    INNER JOIN `profile_names_display` AS n ON ( n.user_id = u.user_id );
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/fusionax-0.0.1/update.sh b/upgrade/fusionax-0.0.1/update.sh
new file mode 100755 (executable)
index 0000000..de82fc0
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+mailman_stop
+mailman_templates
+mailman_start
+
+
+###########################################################
+for sql in *.sql
+do
+    echo -n $sql
+    $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR"
+    echo .
+done
+
+###########################################################
+
+echo "we will now upgrade the search table (this may be a long operation)
+
+please hit ^D to continue
+"
+
+cat
+
+pushd ../../bin
+./search.rebuild_db.php
+popd
+
+###########################################################
+