X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch.php;h=8acb63d047796ef4102a62419695d36231796432;hb=1dc71da137a384e771723b8a893539a7f5cc9fab;hp=9761dd42fffed0cce81a273e517ecfcdcb9a4df6;hpb=2504be33ed7e7436c428f188bdafa9e72248131d;p=platal.git diff --git a/modules/search.php b/modules/search.php index 9761dd4..8acb63d 100644 --- a/modules/search.php +++ b/modules/search.php @@ -1,6 +1,6 @@ log('search', 'quick=' . $quick); } $list = 'profile|prf|fiche|fic|referent|ref|mentor'; - if (S::has_perms()) { + if (S::admin()) { $list .= '|admin|adm|ax'; } if (preg_match('/^(' . $list . '):([-a-z]+(\.[-a-z]+(\.\d{2,4})?)?)$/', replace_accent($quick), $matches)) { @@ -164,19 +164,21 @@ class SearchModule extends PLModule $this->form_prepare(); } else { $textFields = array( - 'country' => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'pays', 'exact' => false), + 'country' => array('field' => 'iso_3166_1_a2', 'table' => 'geoloc_countries', 'text' => 'countryFR', + 'exact' => false), 'fonction' => array('field' => 'id', 'table' => 'fonctions_def', 'text' => 'fonction_fr', 'exact' => true), 'secteur' => array('field' => 'id', 'table' => 'profile_job_sector_enum', 'text' => 'name', 'exact' => false), - 'nationalite' => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'nat', 'exact' => 'false'), + 'nationalite' => array('field' => 'iso_3166_1_a2', 'table' => 'geoloc_countries', + 'text' => 'nationalityFR', 'exact' => 'false'), 'binet' => array('field' => 'id', 'table' => 'binets_def', 'text' => 'text', 'exact' => false), 'networking_type' => array('field' => 'network_type', 'table' => 'profile_networking_enum', 'text' => 'name', 'exact' => false), 'groupex' => array('field' => 'id', 'table' => 'groupex.asso', - 'text' => "(a.cat = 'GroupesX' OR a.cat = 'Institutions') AND pub = 'public' AND nom", + 'text' => "(cat = 'GroupesX' OR cat = 'Institutions') AND pub = 'public' AND nom", 'exact' => false), 'section' => array('field' => 'id', 'table' => 'sections', 'text' => 'text', 'exact' => false), 'school' => array('field' => 'id', 'table' => 'profile_education_enum', 'text' => 'name', 'exact' => false), - 'city' => array('table' => 'geoloc_city', 'text' => 'name', 'exact' => false) + 'city' => array('table' => 'geoloc_localities', 'text' => 'name', 'exact' => false) ); if (!Env::has('page')) { S::logger()->log('search', 'adv=' . var_export($_GET, true)); @@ -270,18 +272,17 @@ class SearchModule extends PLModule $realid = '`profile_networking_enum`.`network_type`'; break; case 'city': - $db = '`geoloc_city` INNER JOIN - `adresses` ON(`geoloc_city`.`id` = `adresses`.`cityid`)'; - $unique='`uid`'; - $field='`geoloc_city`.`name`'; + $db = 'geoloc_localities INNER JOIN + profile_addresses ON (geoloc_localities.id = profile_addresses.localityId)'; + $unique = 'uid'; + $field ='geoloc_localities.name'; break; case 'countryTxt': - $db = '`geoloc_pays` INNER JOIN - `adresses` ON(`geoloc_pays`.`a2` = `adresses`.`country`)'; - $unique = '`uid`'; - $field = '`geoloc_pays`.`pays`'; - $field2 = '`geoloc_pays`.`country`'; - $realid = '`geoloc_pays`.`a2`'; + $db = 'geoloc_countries INNER JOIN + profile_addresses ON (geoloc_countries.iso_3166_1_a2 = profile_addresses.countryId)'; + $unique = 'pid'; + $field = 'geoloc_countries.countryFR'; + $realid = 'geoloc_countries.iso_3166_1_a2'; break; case 'entreprise': $db = 'profile_job_enum INNER JOIN @@ -289,10 +290,6 @@ class SearchModule extends PLModule $field = 'profile_job_enum.name'; $unique = 'profile_job.uid'; break; - case 'firstname': - $field = '`prenom`'; - $beginwith = false; - break; case 'fonctionTxt': $db = 'fonctions_def INNER JOIN profile_job ON (profile_job.fonctionid = fonctions_def.id)'; @@ -313,25 +310,13 @@ class SearchModule extends PLModule $realid = 'a.id'; $unique = 'm.uid'; break; - case 'name': - $field = '`nom`'; - $field2 = '`nom_usage`'; - $beginwith = false; - break; case 'nationaliteTxt': - $db = '`geoloc_pays` INNER JOIN - `auth_user_md5` ON (`geoloc_pays`.`a2` = `auth_user_md5`.`nationalite` OR - `geoloc_pays`.`a2` = `auth_user_md5`.`nationalite2` OR - `geoloc_pays`.`a2` = `auth_user_md5`.`nationalite3`)'; - $field = 'IF(`geoloc_pays`.`nat`=\'\', - `geoloc_pays`.`pays`, - `geoloc_pays`.`nat`)'; - $realid = '`geoloc_pays`.`a2`'; - break; - case 'nickname': - $field = '`profile_nick`'; - $db = '`auth_user_quick`'; - $beginwith = false; + $db = 'geoloc_countries INNER JOIN + auth_user_md5 ON (geoloc_countries.a2 = auth_user_md5.nationalite + OR geoloc_countries.a2 = auth_user_md5.nationalite2 + OR geoloc_countries.a2 = auth_user_md5.nationalite3)'; + $field = 'geoloc_countries.nationalityFR'; + $realid = 'geoloc_countries.iso_3166_1_a2'; break; case 'description': $db = 'profile_job'; @@ -355,7 +340,7 @@ class SearchModule extends PLModule $unique = 'uid'; $beginwith = false; break; - case 'sss_secteur': + case 'subSubSector': $db = 'profile_job_subsubsector_enum'; $field = 'name'; $beginwith = false; @@ -440,9 +425,9 @@ class SearchModule extends PLModule $id = '`network_type`'; break; case 'country': - $db = '`geoloc_pays`'; - $field = '`pays`'; - $id = '`a2`'; + $db = 'geoloc_countries'; + $field = 'countryFR'; + $id = 'iso_3166_1_a2'; $page->assign('onchange', 'changeCountry(this.value)'); break; case 'fonction': @@ -460,19 +445,19 @@ class SearchModule extends PLModule $field = 'nom'; break; case 'nationalite': - $db = '`geoloc_pays` INNER JOIN - `auth_user_md5` ON (`geoloc_pays`.`a2` = `auth_user_md5`.`nationalite` OR - `geoloc_pays`.`a2` = `auth_user_md5`.`nationalite2` OR - `geoloc_pays`.`a2` = `auth_user_md5`.`nationalite3`)'; - $field = 'IF(`nat`=\'\', `pays`, `nat`)'; - $id = '`a2`'; + $db = 'geoloc_countries INNER JOIN + auth_user_md5 ON (geoloc_countries.iso_3166_1_a2 = auth_user_md5.nationalite + OR geoloc_countries.iso_3166_1_a2 = auth_user_md5.nationalite2 + OR geoloc_countries.iso_3166_1_a2 = auth_user_md5.nationalite3)'; + $field = 'nationalityFR'; + $id = 'iso_3166_1_a2'; break; case 'region': - $db = '`geoloc_region`'; - $field = '`name`'; - $id = '`region`'; + $db = 'geoloc_administrativeareas'; + $field = 'name'; + $id = 'id'; if (isset($_REQUEST['country'])) { - $where .= ' WHERE `a2` = "'.$_REQUEST['country'].'"'; + $where .= ' WHERE country = "' . $_REQUEST['country'] . '"'; } break; case 'school':