Cela m'a permis de voir que dans la version actuelle du site, on ne mettait pas à jour le soundex
quand un admin validait un changement de nom !
Avec la nouvelle version, de tels problèmes ne se poseront plus puisqu'on régénère la table de recherche (donc les soundex) entièrement au moins une
fois par jour. Vivement la modularisation pour éviter de telles incohérences...
new_skinned_page('search.tpl', AUTH_PUBLIC);
else
new_skinned_page('search.tpl', AUTH_COOKIE);
+$page->assign('advanced',0);
$page->assign('public_directory',$public_directory);
require_once("applis.func.inc.php");
if ($with_soundex) {
$nameField = new
- StringWithSoundexSField('name',array('s.nom_soundex','s.epouse_soundex','i.nom_soundex'),'r.nom1');
+ StringWithSoundexSField('name',array('r.nom1_soundex','r.nom2_soundex','r.nom3_soundex'),'');
$firstnameField = new
- StringWithSoundexSField('firstname',array('s.prenom_soundex','i.prenom_soundex'),'r.prenom1');
+ StringWithSoundexSField('firstname',array('r.prenom1_soundex','r.prenom2_soundex'),'');
}
else {
$nameField = new StringSField('name',array('r.nom1','r.nom2','r.nom3'),'r.nom1');
ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
c.uid AS contact
- FROM recherche AS r
+ FROM '.(($with_soundex)?'recherche_soundex':'recherche').' AS r
INNER JOIN identification AS i ON (i.matricule=r.matricule)
LEFT JOIN auth_user_md5 AS u ON (u.matricule=r.matricule)
- '.(($with_soundex)?'LEFT JOIN __soundex AS s ON (s.user_id=u.user_id)':'').'
LEFT JOIN contacts AS c ON (c.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).' AND c.contact=u.user_id)
LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
if($no_update_bd) return false;
$alias = ($this->epouse ? $this->alias : "");
- $globals->db->query("UPDATE auth_user_md5 set epouse='".$this->epouse."',epouse_soundex='".soundex_fr($this->epouse)."',alias='".$this->alias."' WHERE user_id=".$this->uid);
+ $globals->db->query("UPDATE auth_user_md5 set epouse='".$this->epouse."',alias='".$this->alias."' WHERE user_id=".$this->uid);
$f = fopen("/tmp/flag_recherche","w");
fputs($f,"1");
fclose($f);
--- /dev/null
+<?php
+require("../../include/xorg.misc.inc.php");
+require("../../include/config.xorg.inc.php");
+
+mysql_connect($globals->dbhost,$globals->dbuser,$globals->dbpwd);
+mysql_select_db($globals->dbdb);
+
+$result = mysql_query("SELECT matricule,nom1,nom2,nom3,prenom1,prenom2,promo FROM recherche");
+
+while ($row = mysql_fetch_row($result)) {
+ list($matricule,$nom1,$nom2,$nom3,$prenom1,$prenom2,$promo) = $row;
+ $sql = "INSERT INTO recherche_soundex
+ (matricule,nom1_soundex,nom2_soundex,nom3_soundex,prenom1_soundex,prenom2_soundex,promo)
+ VALUES($matricule,'".soundex_fr($nom1)."','".soundex_fr($nom2)."','".soundex_fr($nom3)."','".
+ soundex_fr($prenom1)."','".soundex_fr($prenom2)."',$promo)";
+ mysql_query($sql);
+}
+?>
#mode autre = mise à jour si flag
my @args = ("mysql x4dat <recherche.sql");
+my @args2 = ("php recherche.php");
if ($mode==1) {
system(@args);
+ system(@args2);
}
else {
open(INFILE,'</tmp/flag_recherche');
$_ = <INFILE>;
- system(@args)
- if (/1/);
+ if (/1/) {
+ system(@args);
+ system(@args2);
+ }
close INFILE;
open(OUTFILE,'>/tmp/flag_recherche');
print OUTFILE "0";
LOWER(REPLACE(u.nom,'-',' ')) AS nom2, LOWER(REPLACE(u.epouse,'-',' ')) AS nom3,
LOWER(REPLACE(i.prenom,'-',' ')) AS prenom1, LOWER(REPLACE(u.prenom,'-',' ')) AS prenom2,i.promo AS
promo FROM identification AS i LEFT JOIN auth_user_md5 AS u ON (u.matricule=i.matricule);
+DROP TABLE IF EXISTS recherche_soundex;
+CREATE TABLE recherche_soundex (matricule int(8) unsigned PRIMARY KEY,nom1_soundex
+char(4),nom2_soundex char(4),nom3_soundex char(4),prenom1_soundex char(4),prenom2_soundex char(4),
+promo smallint(4) unsigned);