<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2008 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once("xorg.misc.inc.php");
-
// {{{ Global variables used for the search Queries
@$globals->search->result_fields = '
ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
es.label AS secteur, ef.fonction_fr AS fonction,
IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166,
- COUNT(em.email) > 0 AS actif,';
+ (COUNT(em.email) > 0 OR FIND_IN_SET("googleapps", u.mail_storage) > 0) AS actif,';
// hide private information if not logged
if (S::logged())
$globals->search->result_fields .='
*/
private static function defaultHandler($explain)
{
- global $page, $globals;
+ global $globals;
+ $page =& Platal::page();
$page->changeTpl('search/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Annuaire');
+ $page->setTitle('Polytechnique.org - Annuaire');
$page->assign('baseurl', $globals->baseurl);
- $page->trig('Erreur : '.$explain);
+ $page->trigError($explain);
$page->run();
}
}
$s = preg_replace('!\d+!', ' ', $s);
$this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY);
if (count($this->strings) > 5) {
- global $page;
- $page->trig("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
+ Platal::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
$this->strings = array_slice($this->strings, 0, 5);
}
if (Env::i('with_soundex') && strlen($s) > 1) {
$t = soundex_fr($s);
$where[] = "sn$i.soundex = '$t'";
+ } elseif (Env::i('exact')) {
+ $where[] = "sn$i.token = '$s'";
} else {
$t = str_replace('*', '%', $s).'%';
$t = str_replace('%%', '%', $t);
$where[] = 'ems.email = ' . XDB::escape($this->email);
}
if (!empty($this->ip)) {
- $ip = XDB::escape($this->ip);
- $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip )";
+ $ip = ip_to_uint($this->ip);
+ $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0";
}
return join(" AND ", $where);
function compare()
{
$val = addslashes($this->value);
+ if (Env::i('exact')) return "='$val'";
return $this->exact ? "='$val'" : " LIKE '%$val%'";
}
* @param field nom de champ de la bdd concerné par la clause */
function get_single_where_statement($field)
{
- $regexp = strtr(addslashes($this->value), '-*', '_%');
+ $val = addslashes($this->value);
+ if (Env::i('exact')) return "$field = '$val'";
+ $regexp = strtr($val, '-*', '_%');
return "$field LIKE '$regexp%'";
}
function get_single_where_statement($field)
{
- $regexp = strtr(addslashes($this->value), '-*', '_%');
+ $val = addslashes($this->value);
+ if (Env::i('exact')) return "$field = '$val'";
+ $regexp = strtr($val, '-*', '_%');
return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%' OR $field LIKE '%-$regexp%'";
}