From: Raphaël Barrois Date: Thu, 14 Apr 2011 18:44:12 +0000 (+0200) Subject: Fix the search for names containing ' or - . X-Git-Tag: xorg/1.1.1~101 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=5ed1cce8c4b38941d65e578ed3c3bf593a3cc576;p=platal.git Fix the search for names containing ' or - . Signed-off-by: Raphaël Barrois --- diff --git a/classes/profile.php b/classes/profile.php index d9b55b0..73a9fff 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -1087,8 +1087,8 @@ class Profile implements PlExportable continue; } $pid = $key['pid']; - $toks = preg_split('/[ \'\-]+/', strtolower(replace_accent($key['name'])), - -1, PREG_SPLIT_NO_EMPTY); + require_once 'name.func.inc.php'; + $toks = split_name_for_search($key['name']); $toks = array_reverse($toks); /* Split the score between the tokens to avoid the user to be over-rated. diff --git a/include/name.func.inc.php b/include/name.func.inc.php index 8ac831d..d2cbe65 100644 --- a/include/name.func.inc.php +++ b/include/name.func.inc.php @@ -228,6 +228,14 @@ function build_sn_pub($pid) return $sn_old; } +/** Splits a name into tokens, as used in search_name. + * Used for search_name rebuilding and for queries. + */ +function split_name_for_search($name) { + return preg_split('/[[:space:]\'\-]+/', strtolower(replace_accent($name)), + -1, PREG_SPLIT_NO_EMPTY); +} + /** Transform a name to its canonical value so it can be compared * to another form (different case, with accents or with - instead * of blanks). diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index d46d0af..fecc077 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -831,7 +831,9 @@ class UFBF_Name extends UFBF_Text return false; } - $this->val = preg_split('/[[:space:]]/', $this->val); + require_once 'name.func.inc.php'; + + $this->val = split_name_for_search($this->val); if (count($this->val) == 0) { $this->empty = true; }