X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Ffusionax.php;h=54c7fa2a95898bd1b4e0bee99bad72ca788ddb29;hb=34a82c29c450467e5fd0609ce7632a033a7fb3b7;hp=8c0412cfb4230a054a268531ab1d1739cd924955;hpb=5e1513f67936a6c6866113d260746711af4ea2ee;p=platal.git diff --git a/modules/fusionax.php b/modules/fusionax.php index 8c0412c..54c7fa2 100644 --- a/modules/fusionax.php +++ b/modules/fusionax.php @@ -56,7 +56,7 @@ class FusionAxModule extends PLModule } - function handler_index(&$page) + function handler_index($page) { if (Platal::globals()->merge->state == 'pending') { $page->changeTpl('fusionax/index.tpl'); @@ -87,7 +87,7 @@ class FusionAxModule extends PLModule } /** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */ - function handler_import(&$page, $action = 'index', $file = '') + function handler_import($page, $action = 'index', $file = '') { if ($action == 'index') { $page->changeTpl('fusionax/import.tpl'); @@ -111,17 +111,17 @@ class FusionAxModule extends PLModule } else { // séparation de l'archive en fichiers par tables $file = $spoolpath . $file; - // Removes master and doctorate students - exec('grep -v "^[A-Z]\{2\}.[0-9]\{4\}[MD][0-9]\{3\}" ' . $file . ' > ' . $file . '.tmp'); - exec('mv -f ' . $file . '.tmp ' . $file); // Split export into specialised files exec('grep "^AD" ' . $file . ' > ' . $spoolpath . 'Adresses.txt'); exec('grep "^AN" ' . $file . ' > ' . $spoolpath . 'Anciens.txt'); + exec('grep "^FO.[0-9]\{4\}[MD][0-9]\{3\}.Etudiant" ' . $file . ' > ' . $spoolpath . 'Formations_MD.txt'); + exec('grep "^FO.[0-9]\{4\}[MD][0-9]\{3\}.Doct. de" ' . $file . ' >> ' . $spoolpath . 'Formations_MD.txt'); exec('grep "^FO" ' . $file . ' > ' . $spoolpath . 'Formations.txt'); exec('grep "^AC" ' . $file . ' > ' . $spoolpath . 'Activites.txt'); exec('grep "^EN" ' . $file . ' > ' . $spoolpath . 'Entreprises.txt'); exec($modulepath . 'formation.pl'); exec('mv -f ' . $spoolpath . 'Formations_out.txt ' . $spoolpath . 'Formations.txt'); + exec('mv -f ' . $spoolpath . 'Formations_MD_out.txt ' . $spoolpath . 'Formations_MD.txt'); $report[] = 'Fichier parsé.'; $report[] = 'Import dans la base en cours...'; $next = 'integrateSQL'; @@ -134,7 +134,8 @@ class FusionAxModule extends PLModule 1 => 'Adresses.sql', 2 => 'Anciens.sql', 3 => 'Formations.sql', - 4 => 'Entreprises.sql' + 4 => 'Entreprises.sql', + 5 => 'Formations_MD.sql' ); if ($file != '') { // récupère le contenu du fichier sql @@ -157,7 +158,7 @@ class FusionAxModule extends PLModule } else { $nextfile = 0; } - if ($nextfile > 4) { + if ($nextfile > 5) { // tous les fichiers ont été exécutés, on passe à l'étape suivante $next = 'adds1920'; } else { @@ -217,9 +218,9 @@ class FusionAxModule extends PLModule XDB::execute('INSERT INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags) VALUES ({?}, {?}, {?}, {?}, {?}, {?})', $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary'); - XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex) - VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})', - $hrid, $type, 0, 'active', $fullName, $directoryName, $lastname, $sex); + XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, lastname, firstname, sex) + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', + $hrid, $type, 0, 'active', $fullName, $directoryName, $firstname, $lastname, $firstname, $sex); $uid = XDB::insertId(); XDB::execute('INSERT INTO account_profiles (uid, pid, perms) VALUES ({?}, {?}, {?})', @@ -232,11 +233,11 @@ class FusionAxModule extends PLModule SELECT p.pid, p.ax_id, pd.promo, pd.private_name, pd.public_name, pd.sort_name, pd.short_name, pd.directory_name FROM profiles AS p - INNER JOIN profile_display AS pd USING(pid)'); + INNER JOIN profile_display AS pd ON (pd.pid = p.pid)'); $next = 'clean'; } elseif ($action == 'clean') { // nettoyage du fichier temporaire - exec('rm -Rf ' . $spoolpath); + //exec('rm -Rf ' . $spoolpath); $report[] = 'Import finit.'; } foreach($report as $t) { @@ -251,7 +252,7 @@ class FusionAxModule extends PLModule exit; } - function handler_view(&$page, $action = '') + function handler_view($page, $action = '') { $page->changeTpl('fusionax/view.tpl'); if ($action == 'create') { @@ -289,7 +290,7 @@ class FusionAxModule extends PLModule } /* Cherche les les anciens présents dans Xorg avec un matricule_ax ne correspondant à rien dans la base de l'AX - * (mises à part les promo 1921 et 1923 qui ne figurent pas dans les données de l'AX)*/ + * (mises à part les promo 1921, 1923, 1924, 1925 qui ne figurent pas dans les données de l'AX)*/ private static function find_wrong_in_xorg($limit = 10) { return XDB::iterator('SELECT u.promo, u.pid, u.private_name @@ -297,7 +298,7 @@ class FusionAxModule extends PLModule WHERE NOT EXISTS (SELECT * FROM fusionax_anciens AS f WHERE f.ax_id = u.ax_id) - AND u.ax_id IS NOT NULL AND promo != \'X1921\' AND promo != \'X1923\''); + AND u.ax_id IS NOT NULL AND promo NOT IN (\'X1921\', \'X1923\', \'X1924\', \'X1925\')'); } /** Lier les identifiants d'un ancien dans les deux annuaires @@ -332,12 +333,12 @@ class FusionAxModule extends PLModule { $easy_to_link = XDB::iterator(" SELECT u.private_name, u.promo, u.pid, ax.ax_id, - CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X', ax.promotion_etude, ')') AS display_name_ax, + CONCAT(ax.prenom, ' ', ax.nom_complet, ' (', ax.groupe_promo, ax.promotion_etude, ')') AS display_name_ax, COUNT(*) AS nbMatches FROM fusionax_anciens AS ax INNER JOIN fusionax_import AS i ON (i.ax_id = ax.ax_id AND i.pid IS NULL) LEFT JOIN fusionax_xorg_anciens AS u ON (u.ax_id IS NULL - AND u.promo = CONCAT('X', ax.promotion_etude) + AND u.promo = CONCAT(ax.groupe_promo, ax.promotion_etude) AND (CONCAT(ax.prenom, ' ', ax.nom_complet) = u.private_name OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.public_name OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.short_name)) @@ -348,7 +349,7 @@ class FusionAxModule extends PLModule } return XDB::iterator(" SELECT u.private_name, u.promo, u.pid, ax.ax_id, - CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X', ax.promotion_etude, ')') AS display_name_ax, + CONCAT(ax.prenom, ' ', ax.nom_complet, ' (', ax.groupe_promo, ax.promotion_etude, ')') AS display_name_ax, COUNT(*) AS nbMatches FROM fusionax_anciens AS ax INNER JOIN fusionax_import AS i ON (i.ax_id = ax.ax_id AND i.pid IS NULL) @@ -356,14 +357,14 @@ class FusionAxModule extends PLModule AND (CONCAT(ax.prenom, ' ', ax.nom_complet) = u.private_name OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.public_name OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.short_name) - AND u.promo < CONCAT('X', ax.promotion_etude + 2) - AND u.promo > CONCAT('X', ax.promotion_etude - 2)) + AND u.promo < CONCAT(ax.groupe_promo, ax.promotion_etude + 2) + AND u.promo > CONCAT(ax.groupe_promo, ax.promotion_etude - 2)) GROUP BY u.pid HAVING u.pid IS NOT NULL AND nbMatches = 1" . ($limit ? (' LIMIT ' . $limit) : '')); } /** Module de mise en correspondance les ids */ - function handler_ids(&$page, $part = 'main', $pid = null, $ax_id = null) + function handler_ids($page, $part = 'main', $pid = null, $ax_id = null) { $nbToLink = 100; $page->assign('xorg_title', 'Polytechnique.org - Fusion - Mise en correspondance simple'); @@ -373,7 +374,8 @@ class FusionAxModule extends PLModule $page->changeTpl('fusionax/idsMissingInAx.tpl'); $missingInAX = XDB::iterator('SELECT promo, pid, private_name FROM fusionax_xorg_anciens - WHERE ax_id IS NULL'); + WHERE ax_id IS NULL + ORDER BY promo'); $page->assign('missingInAX', $missingInAX); return; } @@ -381,10 +383,11 @@ class FusionAxModule extends PLModule // locate all persons from AX's database that are not here $page->changeTpl('fusionax/idsMissingInXorg.tpl'); $missingInXorg = XDB::iterator("SELECT CONCAT(a.prenom, ' ', a.Nom_usuel) AS private_name, - a.promotion_etude AS promo, a.ax_id + CONCAT(a.groupe_promo, a.promotion_etude) AS promo, a.ax_id FROM fusionax_import INNER JOIN fusionax_anciens AS a USING (ax_id) - WHERE fusionax_import.pid IS NULL"); + WHERE fusionax_import.pid IS NULL + ORDER BY promo"); $page->assign('missingInXorg', $missingInXorg); return; } @@ -450,7 +453,7 @@ class FusionAxModule extends PLModule } } - function handler_deceased(&$page, $action = '') + function handler_deceased($page, $action = '') { if ($action == 'updateXorg') { XDB::execute('UPDATE fusionax_deceased @@ -493,7 +496,7 @@ class FusionAxModule extends PLModule $page->assign('deceasedDifferent', $res); } - function handler_promo(&$page, $action = '') + function handler_promo($page, $action = '') { $page->changeTpl('fusionax/promo.tpl'); $res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo @@ -533,7 +536,7 @@ class FusionAxModule extends PLModule $page->assign('nbMissmatchingPromosTotal', $nbMissmatchingPromos); } - function handler_names(&$page, $action = '') + function handler_names($page, $action = '') { $page->changeTpl('fusionax/names.tpl'); @@ -577,7 +580,7 @@ class FusionAxModule extends PLModule } - function handler_edu(&$page, $action = '') + function handler_edu($page, $action = '') { $page->changeTpl('fusionax/education.tpl'); @@ -608,7 +611,7 @@ class FusionAxModule extends PLModule $page->assign('missingCoupleCount', $missingCouple->total()); } - function handler_corps(&$page) + function handler_corps($page) { $page->changeTpl('fusionax/corps.tpl'); @@ -629,7 +632,7 @@ class FusionAxModule extends PLModule $page->assign('missingGradeCount', $missingGrade->total()); } - function handler_issues_deathdate(&$page, $action = '') + function handler_issues_deathdate($page, $action = '') { $page->changeTpl('fusionax/deathdate_issues.tpl'); if ($action == 'edit') { @@ -671,7 +674,7 @@ class FusionAxModule extends PLModule $page->assign('total', count($issues)); } - function handler_issues_promo(&$page, $action = '') + function handler_issues_promo($page, $action = '') { $page->changeTpl('fusionax/promo_issues.tpl'); if ($action == 'edit') { @@ -718,7 +721,7 @@ class FusionAxModule extends PLModule $page->assign('total', count($issues)); } - function handler_issues(&$page, $action = '') + function handler_issues($page, $action = '') { static $issueList = array( 'name' => 'noms',