/** * $model: The way of presenting the results: minifiche, trombi, geoloc. * $byletter: Show only names beginning with this letter */ function handler_quick($page, $model = null, $byletter = null) { global $globals; if (Env::has('quick') || $model == 'geoloc') { $quick = Env::t('quick'); if (S::logged() && !Env::has('page')) { S::logger()->log('search', 'quick=' . $quick); } if ($quick == '') { $page->trigWarning('Aucun critère de recherche n\'est spécifié.'); $page->changeTpl('search/index.tpl'); $page->setTitle('Annuaire'); $page->assign('formulaire', 1); return; } $list = 'profile|prf|fiche|fic|referent|ref|mentor'; if (S::admin()) { $list .= '|admin|adm|ax'; } $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': $base = 'admin/user/'; break; case 'ax': $base = 'profile/ax/'; break; case 'profile': case 'prf': case 'fiche': case 'fic': $base = 'profile/'; break; case 'referent': case 'ref': case 'mentor': $base = 'referent/'; break; } $user = User::getSilent($login); if ($user) { pl_redirect($base . $user->login()); } Get::set('quick', $login); } elseif (strpos($quick, 'doc:') === 0) { $url = 'Docs/Recherche?'; $url .= 'action=search&q=' . urlencode(substr($quick, 4)); $url .= '&group=' . urlencode('-Equipe,-Main,-PmWiki,-Site,-Review'); pl_redirect($url); } elseif (strpos($quick, 'trombi:') === 0) { $promo = substr($quick, 7); $res = XDB::query("SELECT diminutif\n FROM groups\n WHERE cat = 'Promotions' AND diminutif = {?}", $promo); if ($res->numRows() == 0) { $page->trigWarning("La promotion demandée n'est pas valide: {$promo}"); } else { http_redirect('http://www.polytechnique.net/login/' . $promo . '/annuaire/trombi'); } } $page->assign('formulaire', 0); require_once 'userset.inc.php'; $view = new QuickSearchSet(); $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true, 'starts_with' => $byletter)); $view->addMod('map', 'Planisphère'); if (S::logged() && !Env::i('nonins')) { $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true)); } $view->apply('search', $page, $model); $nb_tot = $view->count(); $page->assign('search_results_nb', $nb_tot); if (!S::logged() && $nb_tot > $globals->search->public_max) { $page->trigError('Votre recherche a généré trop de résultats pour un affichage public.'); } elseif ($nb_tot > $globals->search->private_max) { $page->trigError('Recherche trop générale. Une <a href="search/adv">recherche avancée</a> permet de préciser la recherche.'); } elseif (empty($nb_tot)) { $page->trigError('Il n\'existe personne correspondant à ces critères dans la base !'); } } else { $page->assign('formulaire', 1); } $page->changeTpl('search/index.tpl'); $page->setTitle('Annuaire'); }