X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch.php;h=8173c4a8f092098b083bdb0657db3350856acc97;hb=d6f2c926fa6a88ec2c04cb8c798b0e13d6b915ad;hp=5d474f5d51e7214f2dc4db1d2c440cd811a32bd1;hpb=51fcda846fba31ae18e531a5ceb88178985eb9d2;p=platal.git diff --git a/modules/search.php b/modules/search.php index 5d474f5..8173c4a 100644 --- a/modules/search.php +++ b/modules/search.php @@ -1,6 +1,6 @@ changeTpl('search/index.tpl'); $page->setTitle('Annuaire'); $page->assign('formulaire', 1); - $page->addJsLink('ajax.js'); return; } @@ -74,7 +73,9 @@ class SearchModule extends PLModule if (S::admin()) { $list .= '|admin|adm|ax'; } - if (preg_match('/^(' . $list . '):([-a-z]+(\.[-a-z]+(\.\d{2,4})?)?)$/', replace_accent($quick), $matches)) { + $suffixes = array_keys(DirEnum::getOptions(DirEnum::ACCOUNTTYPES)); + $suffixes = implode('|', $suffixes); + if (preg_match('/^(' . $list . '):([-a-z]+(\.[-a-z]+(\.(?:[md]?\d{2,4}|' . $suffixes . '))?)?)$/', replace_accent($quick), $matches)) { $login = $matches[2]; switch($matches[1]) { case 'admin': case 'adm': @@ -118,7 +119,7 @@ class SearchModule extends PLModule $page->assign('formulaire', 0); require_once 'userset.inc.php'; - $view = new SearchSet(true); + $view = new QuickSearchSet(); $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true, 'starts_with' => $byletter)); if (S::logged() && !Env::i('nonins')) { $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true)); @@ -138,7 +139,6 @@ class SearchModule extends PLModule } } else { $page->assign('formulaire',1); - $page->addJsLink('ajax.js'); } $page->changeTpl('search/index.tpl'); @@ -153,6 +153,12 @@ class SearchModule extends PLModule $page->assign('advanced',1); $page->addJsLink('jquery.autocomplete.js'); + $networks = DirEnum::getOptions(DirEnum::NETWORKS); + $networks[-1] = 'Tous types'; + $networks[0] = '-'; + ksort($networks); + $page->assign('networking_types', $networks); + if (!Env::has('rechercher') && $model != 'geoloc') { $this->form_prepare(); } else { @@ -161,7 +167,10 @@ class SearchModule extends PLModule } require_once 'userset.inc.php'; - $view = new SearchSet(false); + // Enable X.org fields for X.org admins, and AX fields for AX secretaries. + $view = new AdvancedSearchSet(S::admin(), + S::user()->checkPerms(User::PERM_EDIT_DIRECTORY)); + if (!$view->isValid()) { $this->form_prepare(); $page->trigError('Recherche invalide.'); @@ -170,11 +179,17 @@ class SearchModule extends PLModule $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true)); // TODO: Reactivate when the new map is completed. // $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv')); + if (S::user()->checkPerms(User::PERM_EDIT_DIRECTORY) || S::admin()) { + $view->addMod('addresses', 'Adresses postales', false); + } $view->apply('search/adv', $page, $model); $nb_tot = $view->count(); if ($nb_tot > $globals->search->private_max) { $this->form_prepare(); + if ($model != 'addresses' && (S::user()->checkPerms(User::PERM_EDIT_DIRECTORY) || S::admin())) { + $page->assign('suggestAddresses', true); + } $page->trigError('Recherche trop générale.'); } else if ($nb_tot == 0) { $this->form_prepare(); @@ -184,7 +199,6 @@ class SearchModule extends PLModule } $page->changeTpl('search/index.tpl', $model == 'mini' ? SIMPLE : SKINNED); - $page->addJsLink('ajax.js'); $page->assign('public_directory',0); } @@ -258,9 +272,10 @@ class SearchModule extends PLModule if ($nbResults == 0) { $res = $q."|-2\n"; } - XDB::query('REPLACE INTO search_autocomplete - VALUES ({?}, {?}, {?}, NOW())', - $type, $q, $res); + XDB::query('INSERT INTO search_autocomplete (name, query, result, generated) + VALUES ({?}, {?}, {?}, NOW()) + ON DUPLICATE KEY UPDATE result = VALUES(result), generated = VALUES(generated)', + $type, $q, $res); echo $res; exit(); } @@ -298,12 +313,20 @@ class SearchModule extends PLModule case 'nationalite': $ids = DirEnum::getOptionsIter(DirEnum::NATIONALITIES); break; - case 'region': + case 'administrativearea': if (Env::has('country')) { $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS, Env::v('country')); } else { $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS); } + $page->assign('onchange', 'changeAdministrativeArea(this.value)'); + break; + case 'subadministrativearea': + if (Env::has('administrativearea')) { + $ids = DirEnum::getOptionsIter(DirEnum::SUBADMINAREAS, Env::v('administrativearea')); + } else { + $ids = DirEnum::getOptionsIter(DirEnum::SUBADMINAREAS); + } break; case 'school': $ids = DirEnum::getOptionsIter(DirEnum::EDUSCHOOLS); @@ -388,14 +411,14 @@ class SearchModule extends PLModule pl_content_headers("text/xml"); $page->changeTpl('include/field.select.tpl', NO_SKIN); $page->assign('name', 'country'); - $it = XDB::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.countryFR AS field + $it = XDB::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.country AS field FROM geoloc_countries AS gc INNER JOIN profile_mentor_country AS mp ON (mp.country = gc.iso_3166_1_a2) INNER JOIN profile_mentor_term AS mt ON (mt.pid = mp.pid) INNER JOIN profile_job_term_relation AS jtr ON (jtr.jtid_2 = mt.jtid) WHERE jtr.jtid_1 = {?} - GROUP BY iso_3166_1_a2 - ORDER BY countryFR", $jtid); + GROUP BY gc.iso_3166_1_a2 + ORDER BY gc.country", $jtid); $page->assign('list', $it); } }