X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch%2Fsearch.inc.php;h=ea82bdeb2c2e22940a41fea46b71e89cc90354cb;hb=0001ba7a34dc3b535407cb1b961781c3c69c0ccd;hp=f0bf810c460a32263456ad51256bbc9ff2f45754;hpb=a6735b65f3b060a836b6fc56bbc823ce4017d100;p=platal.git diff --git a/modules/search/search.inc.php b/modules/search/search.inc.php index f0bf810..ea82bde 100644 --- a/modules/search/search.inc.php +++ b/modules/search/search.inc.php @@ -1,6 +1,6 @@ array('nom,prenom', true, 'nom', AUTH_PUBLIC), - 'promo' =>array('promo,nom', false, 'promotion', AUTH_PUBLIC), - 'date_mod' =>array('u.date,nom', false, 'dernière modification', AUTH_COOKIE) - ); - - // }}} - // {{{ function setNbLines() - - function setNbLines($lines) - { $this->limit = $lines; } - - // }}} - // {{{ function setAuth() - - function setAuth() - { - foreach ($this->orders as $key=>$o) { - if ($o[3] == AUTH_COOKIE) { - $this->orders[$key][3] = S::logged(); - } elseif ($o[3] == AUTH_PUBLIC) { - $this->orders[$key][3] = true; - } else { - $this->orders[$key][3] = S::identified(); - } - } + $promo1Field = new PromoSField('promo1', 'egal1', array('u.promo'), ''); + $promo2Field = new PromoSField('promo2', 'egal2', array('u.promo'), ''); + $womanField = new RefSField('woman', array('FIND_IN_SET(\'femme\', u.flags) + 1'), '', '', ''); + $subscriberField = new RefSField('subscriber', array('!(u.perms IN (\'admin\', \'user\')) + 1'), '', '', ''); + $aliveField = new RefSField('alive', array('(u.deces != 0) + 1'), '', '', ''); + if (Env::v('only_referent') == 'on') { + $referentField = new RefSField('only_referent', array('"on"'), 'mentor', 'mt', 'mt.expertise != "" AND mt.uid = u.user_id'); + } else { + $referentField = null; } - // }}} - // {{{ function addOrder() - - function addOrder($name, $field, $inv_order, $text, $auth, $defaut=false) - { - // reverse the array, to get the defaut order first - if ($defaut) - $this->orders = array_reverse($this->orders); - $this->orders[$name] = array($field, $inv_order, $text, $auth); - if ($defaut) { - $this->orders = array_reverse($this->orders); - $this->order_defaut = $name; - } + if (!Env::i('cityid')) { + $townField = new RefSField('city', array('ac.city', 'ac.postcode'), 'adresses', 'ac', getadr_join('ac'), false); + } else { + $townField = new RefSField('cityid', array('av.cityid', 'av.postcode'), 'adresses', 'av', getadr_join('av')); } - - // }}} - // {{{ function show() - - function show() - { - $this->setAuth(); - global $page, $globals; - - $offset = intval($this->get_value('offset')); - $tab = @$this->orders[$this->get_value('order')]; - if (!$tab || !$tab[3]) { - $tab = $this->orders[$this->order_defaut]; - } - $order = $tab[0]; - $order_inv = ($this->get_value('order_inv') != '') == $tab[1]; - - if ($order_inv && $order) - $sql_order = str_replace(",", " DESC,", $order)." DESC"; - else $sql_order = $order; - - list($list, $total) = call_user_func($this->_callback, $offset, $this->limit, $sql_order); - - $page_max = intval(($total-1)/$this->limit); - if(!S::logged() && $page_max > $globals->search->public_max) - $page_max = $globals->search->public_max; - - $links = Array(); - if ($offset) { - $links[] = Array('u'=> $this->make_url(Array('offset'=>$offset-1)), 'i' => $offset-1, 'text' => 'précédent'); - } - for ($i = 0; $i <= $page_max ; $i++) { - $links[] = Array('u'=>$this->make_url(Array('offset'=>$i)), 'i' => $i, 'text' => $i+1); - } - if ($offset < $page_max) { - $links[] = Array ('u' => $this->make_url(Array('offset'=>$offset+1)), 'i' => $offset+1, 'text' => 'suivant'); - } - - $page->assign('search_results', $list); - $page->assign('search_results_nb', $total); - $page->assign('search_page', $offset); - $page->assign('search_pages_nb', $page_max+1); - $page->assign('search_pages_link', $links); - - $order_links = Array(); - foreach ($this->orders as $key=>$o) if ($o[3]) { - $order_links[] = Array( - "text" => $o[2], - "url" => $this->make_url(Array('order' => $key, 'order_inv' => ($o[0] == $order) && ($order_inv != $o[1]))), - "asc" => ($o[0] == $order) && $order_inv, - "desc" => ($o[0] == $order) && !$order_inv - ); - } - $page->assign('search_order_link', $order_links); - - return $total; + $countryField = new RefSField('country', array('ap.country'), 'adresses', 'ap', getadr_join('ap')); + $regionField = new RefSField('region',array('ar.region'), 'adresses', 'ar', getadr_join('ar')); + $mapField = new MapSField('mapid', array('sgcim.map_id'), array('adresses', 'geoloc_city_in_maps'), + array('amp', 'sgcim'), array(getadr_join('amp'), 'amp.cityid = sgcim.city_id')); + + $entrepriseField = new RefSField('entreprise', array('je.name'), '', '',''); + $posteField = new RefSField('poste', array('ep.description'), 'profile_job', 'ep', 'u.user_id = ep.uid', false); + $fonctionField = new RefSField('fonction', array('en.fonction_fr'), 'fonctions_def', 'en', + 'u.user_id = profile_job.uid AND fonctions_def.id = profile_job.functionid'); + $secteurField = new RefSField('secteur', array('fm.sectorid'), 'profile_job', 'fm', 'u.user_id = fm.uid'); + $cvField = new RefSField('cv', array('u.cv'), '', '', '', false); + + $natField = new RefSField('nationalite', array('u.nationalite', 'u.nationalite2', 'u.nationalite3'), '', '', ''); + $binetField = new RefSField('binet', array('b.binet_id'), 'binets_ins', 'b', 'u.user_id=b.user_id'); + $groupexField = new RefSField('groupex', array('g.id'), array('groupex.asso', 'groupex.membres'), array('g', 'gm'), + array("(g.cat = 'GroupesX' OR g.cat = 'Institutions') AND g.pub = 'public'", + 'gm.asso_id = g.id AND u.user_id = gm.uid')); + $sectionField = new RefSField('section', array('u.section'), '', '', ''); + $schoolField = new RefSField('school', array('edu.eduid'), 'profile_education', 'edu', 'u.user_id = edu.uid'); + $diplomaField = new RefSField('diploma', array('edd.degreeid'), 'profile_education', 'edd', 'u.user_id = edd.uid'); + + $freeField = new RefSField('free', array('q.profile_freetext'), '', '', '', false); + + $nwAddressField = new RefSField('networking_address', array('nw.address'), 'profile_networking', 'nw', 'nw.uid=u.user_id', false); + if (Env::v('networking_address') == '') { + $nwTypeField = new IndexSField('networking_type', array('nwe.network_type'), array('profile_networking', 'profile_networking_enum'), + array('nw', 'nwe'), array('nw.uid = u.user_id', 'nwe.network_type = nw.network_type')); + } else { + $nwTypeField = new IndexSField('networking_type', + array('nwe.network_type'), 'profile_networking_enum', 'nwe', 'nwe.network_type = nw.network_type'); } - - // }}} + $nwPhoneField = new PhoneSField('phone_number', array('t.search_tel'), 'profile_phones', 't', 't.uid = u.user_id'); + return array( + $nameField, $promo1Field, + $promo2Field, $womanField, $subscriberField, $aliveField, + $townField, $countryField, $regionField, $mapField, $entrepriseField, + $posteField, $secteurField, $cvField, $natField, $binetField, + $groupexField, $sectionField, $schoolField, $diplomaField, + $freeField, $fonctionField, $nwAddressField, $nwTypeField, + $nwPhoneField, $referentField); } // }}} -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>