3 /***************************************************************************
4 * Copyright (C) 2003-2011 Polytechnique.org *
5 * http://opensource.polytechnique.org/ *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 ***************************************************************************/
23 require '../../bin/connect.db.inc.php';
25 $globals->debug
= 0; // Do not store backtraces
28 $res = XDB
::iterator("SELECT p.pid, p.ax_id, p.hrpid,
29 f.Nom_patronymique, f.Nom_usuel, f.Nom_complet,
30 ppn.lastname_initial, ppn.lastname_main, ppn.lastname_marital, ppn.lastname_ordinary
31 FROM fusionax_anciens AS f
32 INNER JOIN profiles AS p ON (f.ax_id = p.ax_id)
33 INNER JOIN profile_public_names AS ppn ON (p.pid = ppn.pid)
36 function format($string)
38 $string = preg_replace('/\-/', ' ', $string);
39 return preg_replace('/\s+/', ' ', $string);
44 $total = $res->total();
45 while ($item = $res->next()) {
46 array_map('trim', $item);
48 'Nom_patronymique' => mb_strtolower(replace_accent($item['Nom_patronymique'])),
49 'Nom_usuel' => mb_strtolower(replace_accent($item['Nom_usuel'])),
50 'Nom_complet' => mb_strtolower(replace_accent($item['Nom_complet']))
53 foreach ($ax_plain as $key => $value) {
54 $ax[$key] = format($value);
57 'lastname_initial' => format(mb_strtolower(replace_accent($item['lastname_initial']))),
58 'lastname_main' => format(mb_strtolower(replace_accent($item['lastname_main']))),
59 'lastname_ordinary' => format(mb_strtolower(replace_accent($item['lastname_ordinary'])))
62 foreach ($xorg as $key => $name) {
63 $ax_key = array_search($name, $ax);
64 if ($ax_key !== false
&& mb_strtolower($item[$ax_key]) != mb_strtolower($item[$key]) && $ax_plain[$ax_key] == mb_strtolower($item[$key])) {
65 XDB
::execute("UPDATE profile_public_names
68 $item[$ax_key], $item['pid']);
74 printf("\r%u / %u", $count, $total);
77 printf("\r%u / %u\n\n", $count, $total);
79 echo "Nombre de mises à jour effectuées : " . $updates_count . ".\n";
81 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: