X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch.php;h=a4cd48169960e439a65bbda7b24698b1ee1c9d85;hb=eaf30d86cc99df2414cf4f171a9b0f11b0561e3b;hp=5a64865a7fd76760f95b389782130b141c59e371;hpb=86b5c8f0b6c9c79b9fb115efca8e6d21b13ec219;p=platal.git diff --git a/modules/search.php b/modules/search.php index 5a64865..a4cd481 100644 --- a/modules/search.php +++ b/modules/search.php @@ -80,7 +80,43 @@ class SearchModule extends PLModule { global $globals; + $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); + if (Env::has('quick') || $action == 'geoloc') { + $quick = trim(Env::v('quick')); + $list = 'profile|prf|fiche|fic|referent|ref|mentor'; + if (S::has_perms()) { + $list .= '|admin|adm|ax'; + } + if (preg_match('/^(' . $list . '):([-a-z]+(\.[-a-z]+(\.\d{2,4})?)?)$/', $quick, $matches)) { + $forlife = $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; + } + pl_redirect($base . $forlife); + } elseif (strpos($quick, 'doc:') === 0) { + $url = 'Docs/Recherche?'; + $url .= 'action=search&q=' . urlencode(substr($quick, 4)); + $url .= '&group=' . urlencode('-Equipe,-Main,-PmWiki,-Site'); + pl_redirect($url); + } + $page->assign('formulaire', 0); require_once 'userset.inc.php'; @@ -88,7 +124,7 @@ class SearchModule extends PLModule $view->addMod('minifiche', 'Minifiches', true, array('with_score' => true)); if (S::logged() && !Env::i('nonins')) { $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true)); - $view->addMod('geoloc', 'Planisphère'); + $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv')); } $view->apply('search', $page, $action, $subaction); @@ -104,20 +140,13 @@ class SearchModule extends PLModule 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'); } require_once dirname(__FILE__) . '/search/search.inc.php'; - $page->changeTpl('search/index.tpl'); + $page->changeTpl('search/index.tpl'); $page->assign('xorg_title','Polytechnique.org - Annuaire'); - $page->assign('baseurl', $globals->baseurl); } function handler_advanced(&$page, $action = null, $subaction = null) @@ -134,9 +163,9 @@ class SearchModule extends PLModule $view = new SearchSet(false, $action == 'geoloc' && substr($subaction, -3) == 'swf'); $view->addMod('minifiche', 'Minifiches', true); $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true)); - $view->addMod('geoloc', 'Planishpère'); + $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv')); $view->apply('search/adv', $page, $action, $subaction); - + if ($subaction) { return; } @@ -170,7 +199,7 @@ class SearchModule extends PLModule $_REQUEST['q']); if (!$q) exit(); - // try to look in cached results + // try to look in cached results $cache = XDB::query('SELECT `result` FROM `search_autocomplete` WHERE `name` = {?} AND @@ -181,15 +210,16 @@ class SearchModule extends PLModule echo $res; die(); } - + // default search + $q = preg_quote($q); $unique = '`user_id`'; $db = '`auth_user_md5`'; $realid = false; $beginwith = true; $field2 = false; $qsearch = $q; - + switch ($type) { case 'binetTxt': $db = '`binets_def` INNER JOIN @@ -218,7 +248,7 @@ class SearchModule extends PLModule $field = '`entreprise`'; $unique='`uid`'; break; - case '`firstname`': + case 'firstname': $field = '`prenom`'; $q = '(^|[ \\-])'.$q; $beginwith = false; @@ -284,7 +314,7 @@ class SearchModule extends PLModule $beginwith = false; break; case 'sectionTxt': - $db = '`sections` INNER JOIN + $db = '`sections` INNER JOIN `auth_user_md5` ON(`auth_user_md5`.`section` = `sections`.`id`)'; $field = '`sections`.`text`'; $realid = '`sections`.`id`'; @@ -332,7 +362,7 @@ class SearchModule extends PLModule echo $res; exit(); } - + function handler_list(&$page, $type = null, $idVal = null) { // Give the list of all values possible of type and builds a select input for it @@ -363,14 +393,15 @@ class SearchModule extends PLModule $db = '`groupesx_def`'; break; case 'nationalite': - $db = '`geoloc_pays`'; + $db = '`geoloc_pays` INNER JOIN + `auth_user_md5` ON (`geoloc_pays`.`a2` = `auth_user_md5`.`nationalite`)'; $field = 'IF(`nat`=\'\', `pays`, `nat`)'; $id = '`a2`'; break; case 'region': $db = '`geoloc_region`'; $field = '`name`'; - $id = '`region`'; + $id = '`region`'; if (isset($_REQUEST['country'])) { $where .= ' WHERE `a2` = "'.$_REQUEST['country'].'"'; } @@ -395,11 +426,12 @@ class SearchModule extends PLModule exit(); } header('Content-Type: text/xml; charset="UTF-8"'); - $page->changeTpl('include/select.field.tpl', NO_SKIN); + $page->changeTpl('include/field.select.tpl', NO_SKIN); $page->assign('name', $type); $page->assign('list', XDB::iterator('SELECT '.$field.' AS field, '.$id.' AS id FROM '.$db.$where.' + GROUP BY '.$field.' ORDER BY '.$field)); } }