Commit | Line | Data |
---|---|---|
b9ad0878 PC |
1 | <?php |
2 | /*************************************************************************** | |
12262f13 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
b9ad0878 PC |
4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
c15c0053 | 22 | /** |
ddc4c642 SJ |
23 | * Module to merge data from AX database: this will only be used once on |
24 | * production site and should be removed afterwards. | |
c15c0053 PC |
25 | * |
26 | * Module to import data from another database of alumni that had | |
27 | * different schemas. The organization that used this db is called AX | |
28 | * hence the name of this module. | |
29 | * | |
ddc4c642 | 30 | * Datas are stored in an export file. |
c15c0053 | 31 | */ |
73be4434 SJ |
32 | class FusionAxModule extends PLModule |
33 | { | |
b9ad0878 PC |
34 | function handlers() |
35 | { | |
654caec5 | 36 | if (Platal::globals()->merge->state == 'pending') { |
12419b5b SJ |
37 | return array( |
38 | 'fusionax' => $this->make_hook('index', AUTH_MDP, 'admin'), | |
39 | 'fusionax/import' => $this->make_hook('import', AUTH_MDP, 'admin'), | |
40 | 'fusionax/view' => $this->make_hook('view', AUTH_MDP, 'admin'), | |
41 | 'fusionax/ids' => $this->make_hook('ids', AUTH_MDP, 'admin'), | |
42 | 'fusionax/deceased' => $this->make_hook('deceased', AUTH_MDP, 'admin'), | |
43 | 'fusionax/promo' => $this->make_hook('promo', AUTH_MDP, 'admin'), | |
2fad6caa | 44 | 'fusionax/names' => $this->make_hook('names', AUTH_MDP, 'admin'), |
551e00c1 SJ |
45 | 'fusionax/edu' => $this->make_hook('edu', AUTH_MDP, 'admin'), |
46 | 'fusionax/corps' => $this->make_hook('corps', AUTH_MDP, 'admin') | |
12419b5b | 47 | ); |
654caec5 | 48 | } elseif (Platal::globals()->merge->state == 'done') { |
12419b5b SJ |
49 | return array( |
50 | 'fusionax' => $this->make_hook('index', AUTH_MDP, 'admin,edit_directory'), | |
51 | 'fusionax/issues' => $this->make_hook('issues', AUTH_MDP, 'admin,edit_directory'), | |
52 | 'fusionax/issues/deathdate' => $this->make_hook('issues_deathdate', AUTH_MDP, 'admin,edit_directory'), | |
53 | 'fusionax/issues/promo' => $this->make_hook('issues_promo', AUTH_MDP, 'admin,edit_directory'), | |
54 | ); | |
654caec5 | 55 | } |
b9ad0878 | 56 | } |
c15c0053 PC |
57 | |
58 | ||
26ba053e | 59 | function handler_index($page) |
b9ad0878 | 60 | { |
654caec5 SJ |
61 | if (Platal::globals()->merge->state == 'pending') { |
62 | $page->changeTpl('fusionax/index.tpl'); | |
63 | } elseif (Platal::globals()->merge->state == 'done') { | |
12419b5b SJ |
64 | $issueList = array( |
65 | 'name' => 'noms', | |
66 | 'job' => 'emplois', | |
67 | 'address' => 'adresses', | |
68 | 'promo' => 'promotions', | |
69 | 'deathdate' => 'dates de décès', | |
70 | 'phone' => 'téléphones', | |
71 | 'education' => 'formations', | |
72 | ); | |
654caec5 SJ |
73 | $issues = XDB::rawFetchOneAssoc("SELECT COUNT(*) AS total, |
74 | SUM(FIND_IN_SET('name', issues)) DIV 1 AS name, | |
75 | SUM(FIND_IN_SET('job', issues)) DIV 2 AS job, | |
76 | SUM(FIND_IN_SET('address', issues)) DIV 3 AS address, | |
77 | SUM(FIND_IN_SET('promo', issues)) DIV 4 AS promo, | |
78 | SUM(FIND_IN_SET('deathdate', issues)) DIV 5 AS deathdate, | |
79 | SUM(FIND_IN_SET('phone', issues)) DIV 6 AS phone, | |
80 | SUM(FIND_IN_SET('education', issues)) DIV 7 AS education | |
81 | FROM profile_merge_issues | |
82 | WHERE issues IS NOT NULL OR issues != ''"); | |
654caec5 | 83 | $page->changeTpl('fusionax/issues.tpl'); |
12419b5b SJ |
84 | $page->assign('issues', $issues); |
85 | $page->assign('issueList', $issueList); | |
654caec5 | 86 | } |
b9ad0878 | 87 | } |
22f043e4 | 88 | |
73be4434 | 89 | /** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */ |
26ba053e | 90 | function handler_import($page, $action = 'index', $file = '') |
b9ad0878 PC |
91 | { |
92 | if ($action == 'index') { | |
93 | $page->changeTpl('fusionax/import.tpl'); | |
b9ad0878 PC |
94 | return; |
95 | } | |
22f043e4 | 96 | |
cc8ea8b2 | 97 | // toutes les actions sont faites en ajax en utilisant jquery |
ddc4c642 | 98 | header('Content-type: text/javascript; charset=utf-8'); |
22f043e4 | 99 | |
cc8ea8b2 PC |
100 | // log des actions |
101 | $report = array(); | |
22f043e4 | 102 | |
73be4434 | 103 | $modulepath = realpath(dirname(__FILE__) . '/fusionax/') . '/'; |
ddc4c642 | 104 | $spoolpath = realpath(dirname(__FILE__) . '/../spool/fusionax/') . '/'; |
22f043e4 | 105 | |
b9ad0878 | 106 | if ($action == 'launch') { |
ddc4c642 SJ |
107 | if ($file == '') { |
108 | $report[] = 'Nom de fichier non renseigné.'; | |
109 | } elseif (!file_exists(dirname(__FILE__) . '/../spool/fusionax/' . $file)) { | |
110 | $report[] = 'Le fichier ne se situe pas au bon endroit.'; | |
111 | } else { | |
112 | // séparation de l'archive en fichiers par tables | |
113 | $file = $spoolpath . $file; | |
ddc4c642 SJ |
114 | // Split export into specialised files |
115 | exec('grep "^AD" ' . $file . ' > ' . $spoolpath . 'Adresses.txt'); | |
116 | exec('grep "^AN" ' . $file . ' > ' . $spoolpath . 'Anciens.txt'); | |
0efb08e6 SJ |
117 | exec('grep "^FO.[0-9]\{4\}[MD][0-9]\{3\}.Etudiant" ' . $file . ' > ' . $spoolpath . 'Formations_MD.txt'); |
118 | exec('grep "^FO.[0-9]\{4\}[MD][0-9]\{3\}.Doct. de" ' . $file . ' >> ' . $spoolpath . 'Formations_MD.txt'); | |
ddc4c642 SJ |
119 | exec('grep "^FO" ' . $file . ' > ' . $spoolpath . 'Formations.txt'); |
120 | exec('grep "^AC" ' . $file . ' > ' . $spoolpath . 'Activites.txt'); | |
121 | exec('grep "^EN" ' . $file . ' > ' . $spoolpath . 'Entreprises.txt'); | |
122 | exec($modulepath . 'formation.pl'); | |
123 | exec('mv -f ' . $spoolpath . 'Formations_out.txt ' . $spoolpath . 'Formations.txt'); | |
0efb08e6 | 124 | exec('mv -f ' . $spoolpath . 'Formations_MD_out.txt ' . $spoolpath . 'Formations_MD.txt'); |
ddc4c642 SJ |
125 | $report[] = 'Fichier parsé.'; |
126 | $report[] = 'Import dans la base en cours...'; | |
127 | $next = 'integrateSQL'; | |
128 | } | |
73be4434 | 129 | } elseif ($action == 'integrateSQL') { |
cc8ea8b2 PC |
130 | // intégration des données dans la base MySQL |
131 | // liste des fichiers sql à exécuter | |
132 | $filesSQL = array( | |
ddc4c642 SJ |
133 | 0 => 'Activites.sql', |
134 | 1 => 'Adresses.sql', | |
135 | 2 => 'Anciens.sql', | |
136 | 3 => 'Formations.sql', | |
0efb08e6 SJ |
137 | 4 => 'Entreprises.sql', |
138 | 5 => 'Formations_MD.sql' | |
ddc4c642 SJ |
139 | ); |
140 | if ($file != '') { | |
cc8ea8b2 | 141 | // récupère le contenu du fichier sql |
ddc4c642 | 142 | $queries = explode(';', file_get_contents($modulepath . $filesSQL[$file])); |
73be4434 SJ |
143 | foreach ($queries as $q) { |
144 | if (trim($q)) { | |
145 | // coupe le fichier en requêtes individuelles | |
146 | if (substr($q, 0, 2) == '--') { | |
147 | // affiche les commentaires dans le report | |
148 | $lines = explode("\n", $q); | |
149 | $l = $lines[0]; | |
150 | $report[] = addslashes($l); | |
151 | } | |
152 | // exécute la requête | |
ddc4c642 | 153 | XDB::execute(str_replace('{?}', $spoolpath, $q)); |
b9ad0878 | 154 | } |
b9ad0878 | 155 | } |
cc8ea8b2 | 156 | // trouve le prochain fichier à exécuter |
ddc4c642 | 157 | $nextfile = $file + 1; |
b9ad0878 PC |
158 | } else { |
159 | $nextfile = 0; | |
160 | } | |
0efb08e6 | 161 | if ($nextfile > 5) { |
ddc4c642 SJ |
162 | // tous les fichiers ont été exécutés, on passe à l'étape suivante |
163 | $next = 'adds1920'; | |
b9ad0878 | 164 | } else { |
cc8ea8b2 | 165 | // on passe au fichier suivant |
ddc4c642 SJ |
166 | $next = 'integrateSQL/' . $nextfile; |
167 | } | |
168 | } elseif ($action == 'adds1920') { | |
169 | // Adds promotion 1920 from AX db. | |
170 | $report[] = 'Ajout de la promotion 1920'; | |
171 | $res = XDB::iterator('SELECT prenom, Nom_complet, ax_id | |
172 | FROM fusionax_anciens | |
173 | WHERE promotion_etude = 1920;'); | |
174 | ||
175 | $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES); | |
176 | $nameTypes = array_flip($nameTypes); | |
177 | $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS); | |
178 | $eduSchools = array_flip($eduSchools); | |
179 | $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); | |
180 | $eduDegrees = array_flip($eduDegrees); | |
181 | $degreeid = $eduDegrees[Profile::DEGREE_X]; | |
182 | $entry_year = 1920; | |
183 | $grad_year = 1923; | |
184 | $promo = 'X1920'; | |
185 | $sex = PlUser::GENDER_MALE; | |
186 | $xorgId = 19200000; | |
187 | $type = 'x'; | |
188 | ||
189 | while (list($firstname, $lastname, $ax_id) = $res->next()) { | |
190 | $hrid = self::getHrid($firstname, $lastname, $promo); | |
191 | $res1 = XDB::query('SELECT COUNT(*) | |
192 | FROM accounts | |
193 | WHERE hruid = {?}', $hrid); | |
194 | $res2 = XDB::query('SELECT COUNT(*) | |
195 | FROM profiles | |
196 | WHERE hrpid = {?}', $hrid); | |
197 | if (is_null($hrid) || $res1->fetchOneCell() > 0 || $res2->fetchOneCell() > 0) { | |
198 | $report[] = $ax_id . ' non ajouté'; | |
199 | } | |
200 | $fullName = $firstname . ' ' . $lastname; | |
201 | $directoryName = $lastname . ' ' . $firstname; | |
202 | ++$xorgId; | |
203 | ||
00ba8a74 SJ |
204 | XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, sex) |
205 | VALUES ({?}, {?}, {?}, {?})', | |
ddc4c642 SJ |
206 | $hrid, $xorgId, $ax_id, $sex); |
207 | $pid = XDB::insertId(); | |
00ba8a74 SJ |
208 | XDB::execute('INSERT INTO profile_name (pid, name, typeid) |
209 | VALUES ({?}, {?}, {?})', | |
ddc4c642 | 210 | $pid, $lastname, $nameTypes['name_ini']); |
00ba8a74 SJ |
211 | XDB::execute('INSERT INTO profile_name (pid, name, typeid) |
212 | VALUES ({?}, {?}, {?})', | |
ddc4c642 | 213 | $pid, $firstname, $nameTypes['firstname_ini']); |
00ba8a74 SJ |
214 | XDB::execute('INSERT INTO profile_display (pid, yourself, public_name, private_name, |
215 | directory_name, short_name, sort_name, promo) | |
216 | VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', | |
ddc4c642 | 217 | $pid, $firstname, $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo); |
00ba8a74 SJ |
218 | XDB::execute('INSERT INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags) |
219 | VALUES ({?}, {?}, {?}, {?}, {?}, {?})', | |
ddc4c642 | 220 | $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary'); |
ad1c9939 SJ |
221 | XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, lastname, firstname, sex) |
222 | VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', | |
223 | $hrid, $type, 0, 'active', $fullName, $directoryName, $firstname, $lastname, $firstname, $sex); | |
ddc4c642 | 224 | $uid = XDB::insertId(); |
00ba8a74 SJ |
225 | XDB::execute('INSERT INTO account_profiles (uid, pid, perms) |
226 | VALUES ({?}, {?}, {?})', | |
ddc4c642 | 227 | $uid, $pid, 'owner'); |
b9ad0878 | 228 | } |
ddc4c642 SJ |
229 | $report[] = 'Promo 1920 ajoutée.'; |
230 | $next = 'view'; | |
231 | } elseif ($action == 'view') { | |
232 | XDB::execute('CREATE OR REPLACE ALGORITHM=MERGE VIEW fusionax_xorg_anciens AS | |
233 | SELECT p.pid, p.ax_id, pd.promo, pd.private_name, pd.public_name, | |
234 | pd.sort_name, pd.short_name, pd.directory_name | |
235 | FROM profiles AS p | |
ad1c9939 | 236 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid)'); |
ddc4c642 | 237 | $next = 'clean'; |
73be4434 | 238 | } elseif ($action == 'clean') { |
cc8ea8b2 | 239 | // nettoyage du fichier temporaire |
0efb08e6 | 240 | //exec('rm -Rf ' . $spoolpath); |
ddc4c642 | 241 | $report[] = 'Import finit.'; |
b9ad0878 | 242 | } |
73be4434 | 243 | foreach($report as $t) { |
cc8ea8b2 | 244 | // affiche les lignes de report |
ddc4c642 | 245 | echo "$('#fusionax').append('" . $t . "<br/>');\n"; |
73be4434 | 246 | } |
b9ad0878 | 247 | if (isset($next)) { |
cc8ea8b2 | 248 | // lance le prochain script s'il y en a un |
ddc4c642 | 249 | echo "$.getScript('fusionax/import/" . $next . "');"; |
b9ad0878 | 250 | } |
cc8ea8b2 | 251 | // exit pour ne pas afficher la page template par défaut |
b9ad0878 PC |
252 | exit; |
253 | } | |
22f043e4 | 254 | |
26ba053e | 255 | function handler_view($page, $action = '') |
29459c49 | 256 | { |
29459c49 SJ |
257 | $page->changeTpl('fusionax/view.tpl'); |
258 | if ($action == 'create') { | |
259 | XDB::execute('DROP VIEW IF EXISTS fusionax_deceased'); | |
723ea674 | 260 | XDB::execute("CREATE VIEW fusionax_deceased AS |
ddc4c642 SJ |
261 | SELECT p.pid, a.ax_id, pd.private_name, pd.promo, p.deathdate AS deces_xorg, a.Date_deces AS deces_ax |
262 | FROM profiles AS p | |
263 | INNER JOIN profile_display AS pd ON (p.pid = pd.pid) | |
264 | INNER JOIN fusionax_anciens AS a ON (a.ax_id = p.ax_id) | |
723ea674 | 265 | WHERE p.deathdate != a.Date_deces OR (p.deathdate IS NULL AND a.Date_deces != '0000-00-00')"); |
29459c49 SJ |
266 | XDB::execute('DROP VIEW IF EXISTS fusionax_promo'); |
267 | XDB::execute('CREATE VIEW fusionax_promo AS | |
ddc4c642 SJ |
268 | SELECT p.pid, p.ax_id, pd.private_name, pd.promo, pe.entry_year AS promo_etude_xorg, |
269 | f.promotion_etude AS promo_etude_ax, pe.grad_year AS promo_sortie_xorg | |
270 | FROM profiles AS p | |
271 | INNER JOIN profile_display AS pd ON (p.pid = pd.pid) | |
272 | INNER JOIN profile_education AS pe ON (p.pid = pe.pid) | |
273 | INNER JOIN fusionax_anciens AS f ON (p.ax_id = f.ax_id) | |
274 | WHERE pd.promo != CONCAT(\'X\', f.promotion_etude) | |
275 | AND !(f.promotion_etude = pe.entry_year + 1 AND pe.grad_year = pe.entry_year + 4)'); | |
276 | $page->trigSuccess('Les VIEW ont bien été créées.'); | |
29459c49 SJ |
277 | } |
278 | } | |
279 | ||
280 | /* Mets à NULL le matricule_ax de ces camarades pour marquer le fait qu'ils ne figurent pas dans l'annuaire de l'AX */ | |
ddc4c642 | 281 | private static function clear_wrong_in_xorg($pid) |
29459c49 | 282 | { |
ddc4c642 SJ |
283 | $res = XDB::execute('UPDATE fusionax_xorg_anciens |
284 | SET ax_id = NULL | |
285 | WHERE pid = {?}', $pid); | |
29459c49 SJ |
286 | if (!$res) { |
287 | return 0; | |
288 | } | |
289 | return XDB::affectedRows() / 2; | |
290 | } | |
291 | ||
aab2ffdd | 292 | /* Cherche les les anciens présents dans Xorg avec un matricule_ax ne correspondant à rien dans la base de l'AX |
ad1c9939 | 293 | * (mises à part les promo 1921, 1923, 1924, 1925 qui ne figurent pas dans les données de l'AX)*/ |
29459c49 SJ |
294 | private static function find_wrong_in_xorg($limit = 10) |
295 | { | |
ddc4c642 | 296 | return XDB::iterator('SELECT u.promo, u.pid, u.private_name |
29459c49 SJ |
297 | FROM fusionax_xorg_anciens AS u |
298 | WHERE NOT EXISTS (SELECT * | |
299 | FROM fusionax_anciens AS f | |
ddc4c642 | 300 | WHERE f.ax_id = u.ax_id) |
ad1c9939 | 301 | AND u.ax_id IS NOT NULL AND promo NOT IN (\'X1921\', \'X1923\', \'X1924\', \'X1925\')'); |
29459c49 SJ |
302 | } |
303 | ||
b65beb64 PC |
304 | /** Lier les identifiants d'un ancien dans les deux annuaires |
305 | * @param user_id identifiant dans l'annuaire X.org | |
306 | * @param matricule_ax identifiant dans l'annuaire de l'AX | |
307 | * @return 0 si la liaison a échoué, 1 sinon | |
22f043e4 | 308 | */ |
ddc4c642 | 309 | private static function link_by_ids($pid, $ax_id) |
b9ad0878 | 310 | { |
ddc4c642 | 311 | $res = XDB::execute('UPDATE fusionax_import AS i |
73be4434 | 312 | INNER JOIN fusionax_xorg_anciens AS u |
ddc4c642 SJ |
313 | SET u.ax_id = i.ax_id, |
314 | i.pid = u.pid, | |
73be4434 | 315 | i.date_match_id = NOW() |
ddc4c642 SJ |
316 | WHERE i.ax_id = {?} AND u.pid = {?} |
317 | AND (u.ax_id != {?} OR u.ax_id IS NULL | |
318 | OR i.pid != {?} OR i.pid IS NULL)', | |
319 | $ax_id, $pid, $ax_id, $pid); | |
73be4434 | 320 | if (!$res) { |
b9ad0878 PC |
321 | return 0; |
322 | } | |
73be4434 | 323 | return XDB::affectedRows() / 2; |
b9ad0878 | 324 | } |
22f043e4 | 325 | |
b65beb64 PC |
326 | /** Recherche automatique d'anciens à lier entre les deux annuaires |
327 | * @param limit nombre d'anciens à trouver au max | |
328 | * @param sure si true, ne trouve que des anciens qui sont quasi sûrs | |
e8591429 | 329 | * @return un XOrgDBIterator sur les entrées avec display_name, promo, |
ddc4c642 | 330 | * pid, ax_id et display_name_ax |
22f043e4 | 331 | */ |
b65beb64 | 332 | private static function find_easy_to_link($limit = 10, $sure = false) |
b9ad0878 | 333 | { |
e8591429 | 334 | $easy_to_link = XDB::iterator(" |
ddc4c642 | 335 | SELECT u.private_name, u.promo, u.pid, ax.ax_id, |
ad1c9939 | 336 | CONCAT(ax.prenom, ' ', ax.nom_complet, ' (', ax.groupe_promo, ax.promotion_etude, ')') AS display_name_ax, |
73be4434 | 337 | COUNT(*) AS nbMatches |
29459c49 | 338 | FROM fusionax_anciens AS ax |
ddc4c642 SJ |
339 | INNER JOIN fusionax_import AS i ON (i.ax_id = ax.ax_id AND i.pid IS NULL) |
340 | LEFT JOIN fusionax_xorg_anciens AS u ON (u.ax_id IS NULL | |
ad1c9939 | 341 | AND u.promo = CONCAT(ax.groupe_promo, ax.promotion_etude) |
ddc4c642 SJ |
342 | AND (CONCAT(ax.prenom, ' ', ax.nom_complet) = u.private_name |
343 | OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.public_name | |
344 | OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.short_name)) | |
345 | GROUP BY u.pid | |
346 | HAVING u.pid IS NOT NULL AND nbMatches = 1" . ($limit ? (' LIMIT ' . $limit) : '')); | |
b65beb64 PC |
347 | if ($easy_to_link->total() > 0 || $sure) { |
348 | return $easy_to_link; | |
349 | } | |
73be4434 | 350 | return XDB::iterator(" |
ddc4c642 | 351 | SELECT u.private_name, u.promo, u.pid, ax.ax_id, |
ad1c9939 | 352 | CONCAT(ax.prenom, ' ', ax.nom_complet, ' (', ax.groupe_promo, ax.promotion_etude, ')') AS display_name_ax, |
73be4434 | 353 | COUNT(*) AS nbMatches |
29459c49 | 354 | FROM fusionax_anciens AS ax |
ddc4c642 SJ |
355 | INNER JOIN fusionax_import AS i ON (i.ax_id = ax.ax_id AND i.pid IS NULL) |
356 | LEFT JOIN fusionax_xorg_anciens AS u ON (u.ax_id IS NULL | |
357 | AND (CONCAT(ax.prenom, ' ', ax.nom_complet) = u.private_name | |
358 | OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.public_name | |
359 | OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.short_name) | |
ad1c9939 SJ |
360 | AND u.promo < CONCAT(ax.groupe_promo, ax.promotion_etude + 2) |
361 | AND u.promo > CONCAT(ax.groupe_promo, ax.promotion_etude - 2)) | |
ddc4c642 SJ |
362 | GROUP BY u.pid |
363 | HAVING u.pid IS NOT NULL AND nbMatches = 1" . ($limit ? (' LIMIT ' . $limit) : '')); | |
b9ad0878 | 364 | } |
22f043e4 | 365 | |
b65beb64 | 366 | /** Module de mise en correspondance les ids */ |
26ba053e | 367 | function handler_ids($page, $part = 'main', $pid = null, $ax_id = null) |
b9ad0878 | 368 | { |
29459c49 | 369 | $nbToLink = 100; |
29459c49 | 370 | $page->assign('xorg_title', 'Polytechnique.org - Fusion - Mise en correspondance simple'); |
ddc4c642 | 371 | |
73be4434 | 372 | if ($part == 'missingInAX') { |
b9ad0878 PC |
373 | // locate all persons from this database that are not in AX's |
374 | $page->changeTpl('fusionax/idsMissingInAx.tpl'); | |
ddc4c642 | 375 | $missingInAX = XDB::iterator('SELECT promo, pid, private_name |
29459c49 | 376 | FROM fusionax_xorg_anciens |
ad1c9939 SJ |
377 | WHERE ax_id IS NULL |
378 | ORDER BY promo'); | |
b9ad0878 PC |
379 | $page->assign('missingInAX', $missingInAX); |
380 | return; | |
381 | } | |
73be4434 | 382 | if ($part == 'missingInXorg') { |
b9ad0878 PC |
383 | // locate all persons from AX's database that are not here |
384 | $page->changeTpl('fusionax/idsMissingInXorg.tpl'); | |
ddc4c642 | 385 | $missingInXorg = XDB::iterator("SELECT CONCAT(a.prenom, ' ', a.Nom_usuel) AS private_name, |
ad1c9939 | 386 | CONCAT(a.groupe_promo, a.promotion_etude) AS promo, a.ax_id |
73be4434 | 387 | FROM fusionax_import |
ddc4c642 | 388 | INNER JOIN fusionax_anciens AS a USING (ax_id) |
ad1c9939 SJ |
389 | WHERE fusionax_import.pid IS NULL |
390 | ORDER BY promo"); | |
b9ad0878 PC |
391 | $page->assign('missingInXorg', $missingInXorg); |
392 | return; | |
393 | } | |
29459c49 SJ |
394 | if ($part == 'wrongInXorg') { |
395 | // locate all persons from Xorg database that have a bad AX id | |
396 | $page->changeTpl('fusionax/idswrongInXorg.tpl'); | |
397 | $wrongInXorg = FusionAxModule::find_wrong_in_xorg($nbToLink); | |
398 | $page->assign('wrongInXorg', $wrongInXorg); | |
399 | return; | |
400 | } | |
401 | if ($part == 'cleanwronginxorg') { | |
402 | $linksToDo = FusionAxModule::find_wrong_in_xorg($nbToLink); | |
403 | while ($l = $linksToDo->next()) { | |
ddc4c642 | 404 | FusionAxModule::clear_wrong_in_xorg($l['pid']); |
29459c49 SJ |
405 | } |
406 | pl_redirect('fusionax/ids/wrongInXorg'); | |
407 | } | |
408 | if ($part == 'lier') { | |
409 | if (Post::has('user_id') && Post::has('matricule_ax')) { | |
ddc4c642 | 410 | FusionAxModule::link_by_ids(Post::i('pid'), Post::v('ax_id')); |
29459c49 SJ |
411 | } |
412 | } | |
73be4434 | 413 | if ($part == 'link') { |
ddc4c642 | 414 | FusionAxModule::link_by_ids($pid, $ax_id); |
b65beb64 | 415 | exit; |
b9ad0878 | 416 | } |
73be4434 | 417 | if ($part == 'linknext') { |
29459c49 | 418 | $linksToDo = FusionAxModule::find_easy_to_link($nbToLink); |
73be4434 | 419 | while ($l = $linksToDo->next()) { |
ddc4c642 | 420 | FusionAxModule::link_by_ids($l['pid'], $l['ax_id']); |
b9ad0878 | 421 | } |
b65beb64 | 422 | pl_redirect('fusionax/ids#autolink'); |
b9ad0878 | 423 | } |
73be4434 | 424 | if ($part == 'linkall') { |
b9ad0878 | 425 | $linksToDo = FusionAxModule::find_easy_to_link(0); |
73be4434 | 426 | while ($l = $linksToDo->next()) { |
ddc4c642 | 427 | FusionAxModule::link_by_ids($l['pid'], $l['ax_id']); |
b9ad0878 PC |
428 | } |
429 | } | |
430 | { | |
431 | $page->changeTpl('fusionax/ids.tpl'); | |
73be4434 | 432 | $missingInAX = XDB::query('SELECT COUNT(*) |
ddc4c642 SJ |
433 | FROM fusionax_xorg_anciens |
434 | WHERE ax_id IS NULL'); | |
73be4434 | 435 | if ($missingInAX) { |
b9ad0878 PC |
436 | $page->assign('nbMissingInAX', $missingInAX->fetchOneCell()); |
437 | } | |
73be4434 | 438 | $missingInXorg = XDB::query('SELECT COUNT(*) |
ddc4c642 SJ |
439 | FROM fusionax_import |
440 | WHERE pid IS NULL'); | |
73be4434 SJ |
441 | if ($missingInXorg) { |
442 | $page->assign('nbMissingInXorg', $missingInXorg->fetchOneCell()); | |
b9ad0878 | 443 | } |
29459c49 SJ |
444 | $wrongInXorg = FusionAxModule::find_wrong_in_xorg($nbToLink); |
445 | if ($wrongInXorg->total() > 0) { | |
446 | $page->assign('wrongInXorg', $wrongInXorg->total()); | |
447 | } | |
448 | $easyToLink = FusionAxModule::find_easy_to_link($nbToLink); | |
449 | if ($easyToLink->total() > 0) { | |
450 | $page->assign('nbMatch', $easyToLink->total()); | |
b9ad0878 PC |
451 | $page->assign('easyToLink', $easyToLink); |
452 | } | |
453 | } | |
454 | } | |
22f043e4 | 455 | |
26ba053e | 456 | function handler_deceased($page, $action = '') |
b9ad0878 | 457 | { |
29459c49 SJ |
458 | if ($action == 'updateXorg') { |
459 | XDB::execute('UPDATE fusionax_deceased | |
460 | SET deces_xorg = deces_ax | |
22648cc5 | 461 | WHERE deces_xorg IS NULL'); |
29459c49 SJ |
462 | } |
463 | if ($action == 'updateAX') { | |
464 | XDB::execute('UPDATE fusionax_deceased | |
465 | SET deces_ax = deces_xorg | |
466 | WHERE deces_ax = "0000-00-00"'); | |
467 | } | |
468 | if ($action == 'update') { | |
ddc4c642 | 469 | if (Post::has('pid') && Post::has('date')) { |
29459c49 SJ |
470 | XDB::execute('UPDATE fusionax_deceased |
471 | SET deces_ax = {?}, deces_xorg = {?} | |
ddc4c642 SJ |
472 | WHERE pid = {?}', |
473 | Post::v('date'), Post::v('date'), Post::i('pid')); | |
29459c49 SJ |
474 | } |
475 | } | |
476 | $page->changeTpl('fusionax/deceased.tpl'); | |
b9ad0878 | 477 | // deceased |
73be4434 SJ |
478 | $deceasedErrorsSql = XDB::query('SELECT COUNT(*) FROM fusionax_deceased'); |
479 | $page->assign('deceasedErrors', $deceasedErrorsSql->fetchOneCell()); | |
ddc4c642 SJ |
480 | $res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_ax |
481 | FROM fusionax_deceased | |
22648cc5 | 482 | WHERE deces_xorg IS NULL |
29459c49 SJ |
483 | LIMIT 10'); |
484 | $page->assign('nbDeceasedMissingInXorg', $res->total()); | |
485 | $page->assign('deceasedMissingInXorg', $res); | |
ddc4c642 SJ |
486 | $res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_xorg |
487 | FROM fusionax_deceased | |
488 | WHERE deces_ax = "0000-00-00" | |
29459c49 SJ |
489 | LIMIT 10'); |
490 | $page->assign('nbDeceasedMissingInAX', $res->total()); | |
491 | $page->assign('deceasedMissingInAX', $res); | |
ddc4c642 SJ |
492 | $res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_xorg, deces_ax |
493 | FROM fusionax_deceased | |
494 | WHERE deces_xorg != "0000-00-00" AND deces_ax != "0000-00-00"'); | |
29459c49 SJ |
495 | $page->assign('nbDeceasedDifferent', $res->total()); |
496 | $page->assign('deceasedDifferent', $res); | |
b9ad0878 | 497 | } |
c7eac294 | 498 | |
26ba053e | 499 | function handler_promo($page, $action = '') |
c7eac294 SJ |
500 | { |
501 | $page->changeTpl('fusionax/promo.tpl'); | |
ddc4c642 | 502 | $res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo |
c7eac294 | 503 | FROM fusionax_promo |
a3f12425 SJ |
504 | WHERE !(promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 3 = promo_sortie_xorg) |
505 | AND !(promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 4 = promo_sortie_xorg) | |
506 | AND !(promo_etude_ax = promo_etude_xorg + 1) | |
507 | ORDER BY promo_etude_xorg'); | |
c7eac294 | 508 | $nbMissmatchingPromos = $res->total(); |
a3f12425 SJ |
509 | $page->assign('nbMissmatchingPromos', $res->total()); |
510 | $page->assign('missmatchingPromos', $res); | |
511 | ||
512 | $res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo | |
513 | FROM fusionax_promo | |
514 | WHERE promo_etude_ax = promo_etude_xorg + 1 | |
515 | ORDER BY promo_etude_xorg'); | |
516 | $nbMissmatchingPromos += $res->total(); | |
c7eac294 SJ |
517 | $page->assign('nbMissmatchingPromos1', $res->total()); |
518 | $page->assign('missmatchingPromos1', $res); | |
a3f12425 | 519 | |
ddc4c642 | 520 | $res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo |
c7eac294 | 521 | FROM fusionax_promo |
a3f12425 SJ |
522 | WHERE promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 3 = promo_sortie_xorg |
523 | ORDER BY promo_etude_xorg'); | |
c7eac294 SJ |
524 | $nbMissmatchingPromos += $res->total(); |
525 | $page->assign('nbMissmatchingPromos2', $res->total()); | |
526 | $page->assign('missmatchingPromos2', $res); | |
a3f12425 SJ |
527 | |
528 | $res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo | |
529 | FROM fusionax_promo | |
530 | WHERE promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 4 = promo_sortie_xorg | |
531 | ORDER BY promo_etude_xorg'); | |
532 | $nbMissmatchingPromos += $res->total(); | |
533 | $page->assign('nbMissmatchingPromos3', $res->total()); | |
534 | $page->assign('missmatchingPromos3', $res); | |
535 | ||
536 | $page->assign('nbMissmatchingPromosTotal', $nbMissmatchingPromos); | |
537 | } | |
538 | ||
26ba053e | 539 | function handler_names($page, $action = '') |
a3f12425 SJ |
540 | { |
541 | $page->changeTpl('fusionax/names.tpl'); | |
542 | ||
543 | $res = XDB::query('SELECT COUNT(*) | |
544 | FROM fusionax_anciens AS f | |
545 | INNER JOIN profiles AS p ON (f.ax_id = p.ax_id)'); | |
546 | $page->assign('total', $res->fetchOneCell()); | |
547 | ||
548 | // To be checked: | |
549 | // | lastname | 1 | | |
550 | // | lastname_marital | 2 | | |
551 | // | lastname_ordinary | 3 | | |
552 | // | firstname | 4 | | |
553 | // | firstname_ordinary | 7 | | |
554 | // | firstname_other | 8 | | |
555 | // | name_other | 9 | | |
556 | // | name_ini | 10 | | |
557 | // | firstname_ini | 11 | | |
558 | $res = XDB::query("SELECT COUNT(*) | |
559 | FROM fusionax_anciens AS f | |
560 | INNER JOIN profiles AS p ON (f.ax_id = p.ax_id) | |
561 | LEFT JOIN profile_name AS pnp ON (p.pid = pnp.pid AND pnp.typeid = 1) | |
562 | LEFT JOIN profile_name AS pnm ON (p.pid = pnm.pid AND pnm.typeid = 2) | |
563 | LEFT JOIN profile_name AS pno ON (p.pid = pno.pid AND pno.typeid = 3) | |
564 | LEFT JOIN profile_name AS pne ON (p.pid = pne.pid AND pne.typeid = 9) | |
565 | LEFT JOIN profile_name AS pni ON (p.pid = pni.pid AND pni.typeid = 10) | |
566 | WHERE IF(f.partic_patro, CONCAT(f.partic_patro, CONCAT(' ', f.Nom_patronymique)), f.Nom_patronymique) NOT IN (pnp.name, pno.name, pnm.name, pne.name, pni.name) | |
567 | OR IF(f.partic_nom, CONCAT(f.partic_nom, CONCAT(' ', f.Nom_usuel)), f.Nom_usuel) NOT IN (pnp.name, pno.name, pnm.name, pne.name, pni.name) | |
568 | OR f.Nom_complet NOT IN (pnp.name, pno.name, pnm.name, pne.name, pni.name)"); | |
569 | $page->assign('lastnameIssues', $res->fetchOneCell()); | |
570 | ||
571 | $res = XDB::query('SELECT COUNT(*) | |
572 | FROM fusionax_anciens AS f | |
573 | INNER JOIN profiles AS p ON (f.ax_id = p.ax_id) | |
574 | LEFT JOIN profile_name AS pnf ON (p.pid = pnf.pid AND pnf.typeid = 4) | |
575 | LEFT JOIN profile_name AS pno ON (p.pid = pno.pid AND pno.typeid = 7) | |
576 | LEFT JOIN profile_name AS pne ON (p.pid = pne.pid AND pne.typeid = 8) | |
577 | LEFT JOIN profile_name AS pni ON (p.pid = pni.pid AND pni.typeid = 11) | |
578 | WHERE f.prenom NOT IN (pnf.name, pno.name, pne.name, pni.name)'); | |
579 | $page->assign('firstnameIssues', $res->fetchOneCell()); | |
580 | ||
c7eac294 | 581 | } |
12419b5b | 582 | |
26ba053e | 583 | function handler_edu($page, $action = '') |
2fad6caa SJ |
584 | { |
585 | $page->changeTpl('fusionax/education.tpl'); | |
586 | ||
95b1a6d8 | 587 | $missingEducation = XDB::rawIterator("SELECT DISTINCT(f.Intitule_formation) |
2fad6caa | 588 | FROM fusionax_formations AS f |
95b1a6d8 SJ |
589 | WHERE f.Intitule_formation != '' AND NOT EXISTS (SELECT * |
590 | FROM profile_education_enum AS e | |
591 | WHERE f.Intitule_formation = e.name)"); | |
592 | $missingDegree = XDB::rawIterator("SELECT DISTINCT(f.Intitule_diplome) | |
2fad6caa | 593 | FROM fusionax_formations AS f |
95b1a6d8 SJ |
594 | WHERE f.Intitule_diplome != '' AND NOT EXISTS (SELECT * |
595 | FROM profile_education_degree_enum AS e | |
596 | WHERE f.Intitule_diplome = e.abbreviation)"); | |
597 | $missingCouple = XDB::rawIterator("SELECT DISTINCT(f.Intitule_formation) AS edu, f.Intitule_diplome AS degree, ee.id AS eduid, de.id AS degreeid | |
2fad6caa | 598 | FROM fusionax_formations AS f |
95b1a6d8 SJ |
599 | INNER JOIN profile_education_enum AS ee ON (f.Intitule_formation = ee.name) |
600 | INNER JOIN profile_education_degree_enum AS de ON (f.Intitule_diplome = de.abbreviation) | |
2fad6caa SJ |
601 | WHERE f.Intitule_diplome != '' AND f.Intitule_formation != '' |
602 | AND NOT EXISTS (SELECT * | |
603 | FROM profile_education_degree AS d | |
604 | WHERE ee.id = d.eduid AND de.id = d.degreeid)"); | |
605 | ||
606 | $page->assign('missingEducation', $missingEducation); | |
607 | $page->assign('missingDegree', $missingDegree); | |
608 | $page->assign('missingCouple', $missingCouple); | |
609 | $page->assign('missingEducationCount', $missingEducation->total()); | |
610 | $page->assign('missingDegreeCount', $missingDegree->total()); | |
611 | $page->assign('missingCoupleCount', $missingCouple->total()); | |
612 | } | |
613 | ||
26ba053e | 614 | function handler_corps($page) |
551e00c1 SJ |
615 | { |
616 | $page->changeTpl('fusionax/corps.tpl'); | |
617 | ||
618 | $missingCorps = XDB::rawIterator('SELECT DISTINCT(f.corps_sortie) AS name | |
619 | FROM fusionax_anciens AS f | |
620 | WHERE NOT EXISTS (SELECT * | |
621 | FROM profile_corps_enum AS c | |
622 | WHERE f.corps_sortie = c.abbreviation)'); | |
623 | $missingGrade = XDB::rawIterator('SELECT DISTINCT(f.grade) AS name | |
624 | FROM fusionax_anciens AS f | |
625 | WHERE NOT EXISTS (SELECT * | |
626 | FROM profile_corps_rank_enum AS c | |
627 | WHERE f.grade = c.name)'); | |
628 | ||
629 | $page->assign('missingCorps', $missingCorps); | |
630 | $page->assign('missingGrade', $missingGrade); | |
631 | $page->assign('missingCorpsCount', $missingCorps->total()); | |
632 | $page->assign('missingGradeCount', $missingGrade->total()); | |
633 | } | |
634 | ||
26ba053e | 635 | function handler_issues_deathdate($page, $action = '') |
12419b5b SJ |
636 | { |
637 | $page->changeTpl('fusionax/deathdate_issues.tpl'); | |
638 | if ($action == 'edit') { | |
639 | S::assert_xsrf_token(); | |
640 | ||
641 | $issues = XDB::rawIterRow('SELECT p.pid, pd.directory_name, pd.promo, pm.deathdate_ax, p.deathdate | |
642 | FROM profile_merge_issues AS pm | |
643 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
644 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid) | |
645 | WHERE FIND_IN_SET(\'deathdate\', pm.issues) | |
646 | ORDER BY pd.directory_name'); | |
647 | while (list($pid, $name, $promo, $deathAX, $deathXorg) = $issues->next()) { | |
648 | $choiceAX = Post::has('AX_' . $pid); | |
649 | $choiceXorg = Post::has('XORG_' . $pid); | |
650 | if (!($choiceAX || $choiceXorg)) { | |
651 | continue; | |
652 | } | |
653 | ||
654 | if ($choiceAX) { | |
655 | XDB::execute('UPDATE profiles AS p | |
656 | INNER JOIN profile_merge_issues AS pm ON (pm.pid = p.pid) | |
657 | SET p.deathdate = pm.deathdate_ax, p.deathdate_rec = NOW() | |
658 | WHERE p.pid = {?}', $pid); | |
659 | } | |
660 | XDB::execute("UPDATE profile_merge_issues | |
661 | SET issues = REPLACE(issues, 'deathdate', '') | |
662 | WHERE pid = {?}", $pid()); | |
663 | $page->trigSuccess("La date de décès de $name ($promo) a bien été corrigée."); | |
664 | } | |
665 | } | |
666 | ||
667 | $issues = XDB::rawFetchAllAssoc('SELECT p.pid, p.hrpid, pd.directory_name, pd.promo, pm.deathdate_ax, p.deathdate | |
668 | FROM profile_merge_issues AS pm | |
669 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
670 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid) | |
671 | WHERE FIND_IN_SET(\'deathdate\', pm.issues) | |
672 | ORDER BY pd.directory_name'); | |
673 | $page->assign('issues', $issues); | |
674 | $page->assign('total', count($issues)); | |
675 | } | |
676 | ||
26ba053e | 677 | function handler_issues_promo($page, $action = '') |
12419b5b SJ |
678 | { |
679 | $page->changeTpl('fusionax/promo_issues.tpl'); | |
680 | if ($action == 'edit') { | |
681 | S::assert_xsrf_token(); | |
682 | ||
683 | $issues = XDB::rawIterRow('SELECT p.pid, pd.directory_name, pd.promo, pm.entry_year_ax, pe.entry_year, pe.grad_year | |
684 | FROM profile_merge_issues AS pm | |
685 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
686 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid) | |
687 | INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags)) | |
688 | WHERE FIND_IN_SET(\'promo\', pm.issues) | |
689 | ORDER BY pd.directory_name'); | |
690 | while (list($pid, $name, $promo, $deathAX, $deathXorgEntry, $deathXorgGrad) = $issues->next()) { | |
691 | $choiceXorg = Post::has('XORG_' . $pid); | |
692 | if (!(Post::has('display_' . $pid) && Post::has('entry_' . $pid) && Post::has('grad_' . $pid))) { | |
693 | continue; | |
694 | } | |
695 | ||
696 | $display = Post::i('display_' . $pid); | |
697 | $entry = Post::i('entry_' . $pid); | |
698 | $grad = Post::i('grad_' . $pid); | |
699 | if (!(($grad <= $entry + 5 && $grad >= $entry + 3) && ($display >= $entry && $display <= $grad - 3))) { | |
700 | $page->trigError("La promotion de $name n'a pas été corrigée."); | |
701 | continue; | |
702 | } | |
703 | XDB::execute('UPDATE profile_display | |
704 | SET promo = {?} | |
705 | WHERE pid = {?}', 'X' . $display, $pid); | |
706 | XDB::execute('UPDATE profile_education | |
707 | SET entry_year = {?}, grad_year = {?} | |
708 | WHERE pid = {?} AND FIND_IN_SET(\'primary\', flags)', $entry, $grad, $pid); | |
709 | $page->trigSuccess("La promotion de $name a bien été corrigée."); | |
710 | } | |
711 | } | |
712 | ||
713 | $issues = XDB::rawFetchAllAssoc('SELECT p.pid, p.hrpid, pd.directory_name, pd.promo, pm.entry_year_ax, pe.entry_year, pe.grad_year | |
714 | FROM profile_merge_issues AS pm | |
715 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
716 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid) | |
717 | INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags)) | |
718 | WHERE FIND_IN_SET(\'promo\', pm.issues) | |
719 | ORDER BY pd.directory_name'); | |
720 | $page->assign('issues', $issues); | |
721 | $page->assign('total', count($issues)); | |
722 | } | |
723 | ||
26ba053e | 724 | function handler_issues($page, $action = '') |
12419b5b SJ |
725 | { |
726 | static $issueList = array( | |
727 | 'name' => 'noms', | |
728 | 'phone' => 'téléphones', | |
729 | 'education' => 'formations', | |
730 | 'address' => 'adresses', | |
731 | 'job' => 'emplois' | |
732 | ); | |
d20f50cf SJ |
733 | static $typeList = array( |
734 | 'name' => 'general', | |
735 | 'phone' => 'general', | |
736 | 'education' => 'general', | |
737 | 'address' => 'adresses', | |
738 | 'job' => 'emploi' | |
739 | ); | |
12419b5b SJ |
740 | |
741 | if (!array_key_exists($action, $issueList)) { | |
742 | pl_redirect('fusionax'); | |
743 | } else { | |
744 | $total = XDB::fetchOneCell('SELECT COUNT(*) | |
745 | FROM profile_merge_issues | |
746 | WHERE FIND_IN_SET({?}, issues)', $action); | |
747 | if ($total == 0) { | |
748 | pl_redirect('fusionax'); | |
749 | } | |
750 | ||
751 | $issues = XDB::fetchAllAssoc('SELECT p.hrpid, pd.directory_name, pd.promo | |
752 | FROM profile_merge_issues AS pm | |
753 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
754 | INNER JOIN profile_display AS pd ON (pd.pid = p.pid) | |
755 | WHERE FIND_IN_SET({?}, pm.issues) | |
756 | ORDER BY pd.directory_name | |
757 | LIMIT 100', $action); | |
758 | ||
759 | $page->changeTpl('fusionax/other_issues.tpl'); | |
760 | $page->assign('issues', $issues); | |
761 | $page->assign('issue', $issueList[$action]); | |
d20f50cf | 762 | $page->assign('type', $typeList[$action]); |
12419b5b SJ |
763 | $page->assign('total', $total); |
764 | } | |
765 | } | |
b9ad0878 | 766 | } |
e8591429 | 767 | |
a3f12425 SJ |
768 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
769 | ?> |