X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch%2Fclasses.inc.php;h=406664e9f184808b2bd36174dd32e56b2428cea3;hb=d7610c358d074c78e1e8dc25fe0cf0e5e7e1c55e;hp=edebc8cffffd67c898bb7486cfe74adbcb6886d5;hpb=787bb3d745141f2f85bd947ad7dd775d2c63f908;p=platal.git diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index edebc8c..406664e 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -1,6 +1,6 @@ 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 .=' @@ -92,11 +92,12 @@ class ThrowError */ 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->assign('baseurl', $globals->baseurl); - $page->trig('Erreur : '.$explain); + $page->trigError($explain); $page->run(); } } @@ -252,6 +253,10 @@ class QuickSearch extends SField $s = preg_replace('!\d+!', ' ', $s); $this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY); + if (count($this->strings) > 5) { + 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); + } $s = preg_replace('! *- *!', '-', $r); $s = preg_replace('!([<>]) *!', ' \1', $s); @@ -302,8 +307,8 @@ class QuickSearch extends SField $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); @@ -468,7 +473,16 @@ class RefSField extends SField return false; } $res = implode(' OR ', array_filter(array_map(array($this, 'get_single_match_statement'), $this->fieldDbName))); - return "INNER JOIN {$this->refTable} AS {$this->refAlias} ON ({$this->refCondition} AND ($res) )"; + if (is_array($this->refTable)) { + foreach ($this->refTable as $i => $refT) + $last = $i; + $inner = ""; + foreach ($this->refTable as $i => $refT) + $inner .= " INNER JOIN {$refT} AS {$this->refAlias[$i]} ON ({$this->refCondition[$i]} ".(($i == $last)?"AND ($res) ":"").")\n"; + return $inner; + } else { + return "INNER JOIN {$this->refTable} AS {$this->refAlias} ON ({$this->refCondition} AND ($res) )"; + } } // }}} @@ -741,6 +755,11 @@ class SFieldGroup { $this->fields = $_fields; $this->and = $_and; + foreach ($this->fields as $key=>&$field) { + if (is_null($field)) { + unset($this->fields[$key]); + } + } } // }}} @@ -750,7 +769,9 @@ class SFieldGroup { $b = true; for ($i=0 ; $b && $ifields) ; $i++) { - $b = $b && $this->fields[$i]->too_large(); + if (!is_null($this->fields[$i])) { + $b = $b && $this->fields[$i]->too_large(); + } } return $b; }