* Search:
- #911: Adds search on corps -JAC
- #990: Adds search on broken redirections -JAC
+ - #1469: Adds search on firstname/lastname/nickname -JAC
- #1470: Fixes autocomplete on countries -JAC
* XnetList:
if (!is_array($pids)) {
$pids = array($pids);
}
- $keys = XDB::iterator("(SELECT n.pid AS pid, n.name AS name, e.score AS score,
+ $keys = XDB::iterator("(SELECT n.pid AS pid, n.name AS name, e.score AS score, e.general_type,
IF(FIND_IN_SET('public', e.flags), 'public', '') AS public
FROM profile_name AS n
INNER JOIN profile_name_enum AS e ON (n.typeid = e.id)
WHERE n.pid IN {?} AND NOT FIND_IN_SET('not_displayed', e.flags))
UNION
- (SELECT n.pid AS pid, n.particle AS name, 0 AS score,
+ (SELECT n.pid AS pid, n.particle AS name, 0 AS score, e.general_type,
IF(FIND_IN_SET('public', e.flags), 'public', '') AS public
FROM profile_name AS n
INNER JOIN profile_name_enum AS e ON (n.typeid = e.id)
$token = '';
foreach ($toks as $tok) {
$token = $tok . $token;
- $names["$pid-$token"] = XDB::format('({?}, {?}, {?}, {?}, {?})',
+ $names["$pid-$token"] = XDB::format('({?}, {?}, {?}, {?}, {?}, {?})',
$token, $pid, soundex_fr($token),
- $eltScore, $key['public']);
+ $eltScore, $key['public'], $key['general_type']);
}
}
if ($transaction) {
WHERE pid IN {?}',
$pids);
if (count($names) > 0) {
- XDB::rawExecute('INSERT INTO search_name (token, pid, soundex, score, flags)
+ XDB::rawExecute('INSERT INTO search_name (token, pid, soundex, score, flags, general_type)
VALUES ' . implode(', ', $names));
}
if ($transaction) {
private $flags;
private $soundex;
private $exact;
+ private $general_type;
- public function __construct($tokens, $flags = array(), $soundex = false, $exact = false)
+ public function __construct($tokens, $flags = array(), $soundex = false, $exact = false, $general_type = '')
{
if (is_array($tokens)) {
$this->tokens = $tokens;
}
$this->soundex = $soundex;
$this->exact = $exact;
+ $this->general_type = $general_type;
}
public function buildCondition(PlFilter $uf)
if ($this->flags != null) {
$c .= XDB::format(' AND ' . $sub . '.flags IN {?}', $this->flags);
}
+ if ($this->general_type) {
+ $c .= XDB::format(' AND ' . $sub . '.general_type = {?}', $this->general_type);
+ }
$conds[] = $c;
}
public function __construct($include_admin = false, $include_ax = false, $envprefix = '')
{
$fields = array(
- new UFBF_Name('name', 'Nom'),
+ new UFBF_Name('name', 'Nom', 'name_type'),
new UFBF_Promo('promo1', 'Promotion', 'egal1', 'edu_type'),
new UFBF_Promo('promo2', 'Promotion', 'egal2', 'edu_type'),
new UFBF_Sex('woman', 'Sexe'),
// {{{ class UFBF_Name
class UFBF_Name extends UFBF_Text
{
+ private $envfieldtype;
+ private $type;
+
+ public function __construct($envfield, $formtext = '', $envfieldtype)
+ {
+ parent::__construct($envfield, $formtext);
+ $this->envfieldtype = $envfieldtype;
+ }
+
protected function check(UserFilterBuilder $ufb)
{
if (!parent::check($ufb)) {
if (count($this->val) == 0) {
$this->empty = true;
}
+ $this->type = $ufb->v($this->envfieldtype);
+ if (!in_array($this->type, array('', 'lastname', 'firstname', 'nickname'))) {
+ return $this->raise("Le critère {$this->type} n'est pas valide pour le champ %s");
+ }
return true;
}
protected function buildUFC(UserFilterBuilder $ufb)
{
- return new UFC_NameTokens($this->val, array(), $ufb->b('with_soundex'), $ufb->b('exact'));
+ return new UFC_NameTokens($this->val, array(), $ufb->b('with_soundex'), $ufb->b('exact'), $this->type);
+ }
+
+ public function getEnvFieldNames()
+ {
+ return array($this->envfield, $this->envfieldtype);
}
}
// }}}
<input type="hidden" name="rechercher" value="Chercher"/>
<input type="submit" style="display:none"/>
<input type="text" name="name" size="32" value="{$smarty.request.name}" />
+ <select name="name_type">
+ <option value="" {if $smarty.request.name_type eq ''}selected="selected"{/if}> - </option>
+ <option value="lastname" {if $smarty.request.name_type eq 'lastname'}selected="selected"{/if}>nom</option>
+ <option value="firstname" {if $smarty.request.name_type eq 'firstname'}selected="selected"{/if}>prénom</option>
+ <option value="nickname" {if $smarty.request.name_type eq 'nickname'}selected="selected"{/if}>surnom</option>
+ </select>
</td>
</tr>
<tr>
--- /dev/null
+ALTER TABLE profile_name_enum ADD COLUMN general_type ENUM('lastname', 'firstname', 'nickname') NOT NULL DEFAULT 'lastname';
+
+UPDATE profile_name_enum
+ SET general_type = 'lastname'
+ WHERE type LIKE 'lastname%' OR type LIKE 'name_%';
+UPDATE profile_name_enum
+ SET general_type = 'firstname'
+ WHERE type LIKE 'firstname%';
+UPDATE profile_name_enum
+ SET general_type = 'nickname'
+ WHERE type IN ('pseudonym', 'nickname');
+
+ALTER TABLE search_name ADD COLUMN general_type ENUM('lastname', 'firstname', 'nickname') NOT NULL DEFAULT 'lastname';
+
+-- vim:set syntax=mysql:
The following variable should be set:
[Core]
baseurl_shortener = "http://u.w4x.org/"
+
+Run bin/search.rebuild_db.php after release to enable search on firstname/lastname/nickname.