X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch.php;h=8aa13cf42ec57304dc1263db9c837938b413cf49;hb=63c81443a0000525310d8c554b630782f914b65e;hp=d76117585d77769893cde651b3f96a50be7b840a;hpb=2aa20e30505a0d1acc7ad1a2ebf74d001a4167f7;p=platal.git diff --git a/modules/search.php b/modules/search.php index d761175..8aa13cf 100644 --- a/modules/search.php +++ b/modules/search.php @@ -1,6 +1,6 @@ $this->make_hook('quick', AUTH_PUBLIC), 'search/adv' => $this->make_hook('advanced', AUTH_COOKIE), - 'search/ajax/region' => $this->make_hook('region', AUTH_COOKIE, '', NO_AUTH), - 'search/ajax/grade' => $this->make_hook('grade', AUTH_COOKIE, '', NO_AUTH), + 'search/ajax/region' => $this->make_hook('region', AUTH_COOKIE, 'user', NO_AUTH), + 'search/ajax/grade' => $this->make_hook('grade', AUTH_COOKIE, 'user', NO_AUTH), 'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC), ); } @@ -47,11 +47,14 @@ class SearchModule extends PLModule function get_quick($offset, $limit, $order) { global $globals; + if (!S::logged()) { + Env::kill('with_soundex'); + } $qSearch = new QuickSearch('quick'); $fields = new SFieldGroup(true, array($qSearch)); if ($qSearch->isempty()) { - new ThrowError('Recherche trop générale.'); + new ThrowError('Recherche trop générale.'); } $sql = 'SELECT SQL_CALC_FOUND_ROWS @@ -90,8 +93,11 @@ class SearchModule extends PLModule $page->assign('formulaire',1); $page->assign('choix_nats', - XDB::iterator('SELECT a2 AS id,IF(nat=\'\',pays,nat) AS text - FROM geoloc_pays ORDER BY text')); + XDB::iterator('SELECT g.a2 AS id, IF(nat=\'\', g.pays, g.nat) AS text + FROM geoloc_pays AS g + INNER JOIN auth_user_md5 AS u ON (u.nationalite = g.a2) + GROUP BY g.a2 + ORDER BY text')); $page->assign('choix_postes', XDB::iterator('SELECT id,fonction_fr FROM fonctions_def ORDER BY fonction_fr')); @@ -137,7 +143,7 @@ class SearchModule extends PLModule $fields = new SFieldGroup(true, advancedSearchFromInput()); if ($fields->too_large()) { $this->form_prepare(); - new ThrowError('Recherche trop générale.'); + new ThrowError('Recherche trop générale.'); } global $globals, $page; @@ -198,14 +204,21 @@ class SearchModule extends PLModule $nb_tot = $search->show(); if (!S::logged() && $nb_tot > $globals->search->public_max) { - new ThrowError('Votre recherche a généré trop de résultats pour un affichage public.'); + new ThrowError('Votre recherche a généré trop de résultats pour un affichage public.'); } elseif ($nb_tot > $globals->search->private_max) { - new ThrowError('Recherche trop générale'); + new ThrowError('Recherche trop générale'); } elseif (empty($nb_tot)) { - new ThrowError('il n\'existe personne correspondant à ces critères dans la base !'); + new ThrowError('il n\'existe personne correspondant à ces critères dans la base !'); } } else { + $res = XDB::query("SELECT MIN(diminutif), MAX(diminutif) + FROM groupex.asso + WHERE cat = 'Promotions'"); + list($min, $max) = $res->fetchOneRow(); + $page->assign('promo_min', $min); + $page->assign('promo_max', $max); $page->assign('formulaire',1); + $page->addJsLink('ajax.js'); } $page->register_modifier('display_lines', 'display_lines'); @@ -228,20 +241,18 @@ class SearchModule extends PLModule if (!Env::has('rechercher')) { $this->form_prepare(); } else { - $search = new XOrgSearch(array($this, 'get_advanced')); $search->setNbLines($globals->search->per_page); $page->assign('url_search_form', $search->make_url(Array('rechercher'=>0))); - if (Env::has('with_soundex')) { - $page->assign('with_soundex', $search->make_url(Array())."&with_soundex=1"); + if (!Env::i('with_soundex')) { + $page->assign('with_soundex', $search->make_url(Array()) . "&with_soundex=1"); } - $nb_tot = $search->show(); if ($nb_tot > $globals->search->private_max) { $this->form_prepare(); - new ThrowError('Recherche trop générale'); + new ThrowError('Recherche trop générale'); } } @@ -252,7 +263,7 @@ class SearchModule extends PLModule function handler_region(&$page, $country = null) { - header('Content-Type: text/html; charset="iso-8859-15"'); + header('Content-Type: text/html; charset="UTF-8"'); require_once("geoloc.inc.php"); $page->ChangeTpl('search/adv.region.form.tpl', NO_SKIN); $page->assign('region', ""); @@ -261,11 +272,12 @@ class SearchModule extends PLModule function handler_grade(&$page, $school = null) { - header('Content-Type: text/html; charset="iso-8859-15"'); + header('Content-Type: text/html; charset="UTF-8"'); $page->ChangeTpl('search/adv.grade.form.tpl', NO_SKIN); $page->assign('grade', ''); $this->get_diplomas($school); } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>