X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fsearch.php;h=9f26a73fd9d4f218b94a4d904d3e84324cbcde42;hb=b40deec06338bd63a5b4d6b9ead0166506ce049d;hp=ea8491ad0831190a651408a52f7e084b4c5db77b;hpb=ff3eb9b7ade4406804e721579111384a768e7791;p=platal.git diff --git a/modules/search.php b/modules/search.php index ea8491a..9f26a73 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'; @@ -104,12 +140,6 @@ 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'); } @@ -117,7 +147,6 @@ class SearchModule extends PLModule require_once dirname(__FILE__) . '/search/search.inc.php'; $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,8 +163,8 @@ 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->apply('search', $page, $action, $subaction); + $view->addMod('geoloc', 'Planisphère'); + $view->apply('search/adv', $page, $action, $subaction); if ($subaction) { return; @@ -183,6 +212,7 @@ class SearchModule extends PLModule } // default search + $q = preg_quote($q); $unique = '`user_id`'; $db = '`auth_user_md5`'; $realid = false; @@ -218,7 +248,7 @@ class SearchModule extends PLModule $field = '`entreprise`'; $unique='`uid`'; break; - case '`firstname`': + case 'firstname': $field = '`prenom`'; $q = '(^|[ \\-])'.$q; $beginwith = false; @@ -363,7 +393,8 @@ 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; @@ -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)); } }