Merge branch 'master' into fusionax
[platal.git] / modules / search / search.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
8d84c630 3 * Copyright (C) 2003-2009 Polytechnique.org *
0337d704 4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
abc68084 22require_once dirname(__FILE__).'/classes.inc.php';
0337d704 23
56670b6a 24// {{{ function advancedSearchFromInput
e4cd7a1f 25function getAddressJoin($table) {
d6eb0554 26 return 'u.user_id = ' . $table . '.pid' . (Env::v('only_current', false) ? ' AND FIND_IN_SET(\'current\', ' . $table . '.flags)' : '');
2b105fb6 27}
56670b6a 28function advancedSearchFromInput()
29{
30 if ($with_soundex = Env::has('with_soundex')) {
6443c93d
SJ
31 $nameField = new RefWithSoundexSField('name', array('n.soundex'), 'search_name',
32 'n', 'u.user_id = n.uid');
56670b6a 33 } else {
6443c93d 34 $nameField = new NameSField('name', array('n.token'), 'search_name', 'n', 'u.user_id = n.uid');
56670b6a 35 }
eaf30d86 36
2398e553
SJ
37 $promo1Field = new PromoSField('promo1', 'egal1', array('u.promo'), '');
38 $promo2Field = new PromoSField('promo2', 'egal2', array('u.promo'), '');
39 $womanField = new RefSField('woman', array('FIND_IN_SET(\'femme\', u.flags) + 1'), '', '', '');
40 $subscriberField = new RefSField('subscriber', array('!(u.perms IN (\'admin\', \'user\')) + 1'), '', '', '');
41 $aliveField = new RefSField('alive', array('(u.deces != 0) + 1'), '', '', '');
63fac48e 42 if (Env::v('only_referent') == 'on') {
2398e553 43 $referentField = new RefSField('only_referent', array('"on"'), 'mentor', 'mt', 'mt.expertise != "" AND mt.uid = u.user_id');
63fac48e 44 } else {
2398e553 45 $referentField = null;
63fac48e 46 }
56670b6a 47
e4cd7a1f
SJ
48 $townField = new RefSField('city', array('av.localityId', 'av.postalCode'), 'profile_addresses',
49 'av', getAddressJoin('av'));
50 $countryField = new RefSField('country', array('ap.countryId'), 'profile_addresses', 'ap', getAddressJoin('ap'));
51 $regionField = new RefSField('region',array('ar.administrativeAreaId'), 'profile_addresses', 'ar', getAddressJoin('ar'));
a2aa8436 52
e6e9b2dd 53 $entrepriseField = new RefSField('entreprise', array('je.name'), '', '','');
c7139c07
SJ
54 $posteField = new RefSField('poste', array('ep.description'), 'profile_job', 'ep', 'u.user_id = ep.uid', false);
55 $fonctionField = new RefSField('fonction', array('en.fonction_fr'), 'fonctions_def', 'en',
56 'u.user_id = profile_job.uid AND fonctions_def.id = profile_job.functionid');
57 $secteurField = new RefSField('secteur', array('fm.sectorid'), 'profile_job', 'fm', 'u.user_id = fm.uid');
2398e553 58 $cvField = new RefSField('cv', array('u.cv'), '', '', '', false);
eaf30d86 59
2398e553
SJ
60 $natField = new RefSField('nationalite', array('u.nationalite', 'u.nationalite2', 'u.nationalite3'), '', '', '');
61 $binetField = new RefSField('binet', array('b.binet_id'), 'binets_ins', 'b', 'u.user_id=b.user_id');
62 $groupexField = new RefSField('groupex', array('g.id'), array('groupex.asso', 'groupex.membres'), array('g', 'gm'),
63 array("(g.cat = 'GroupesX' OR g.cat = 'Institutions') AND g.pub = 'public'",
64 'gm.asso_id = g.id AND u.user_id = gm.uid'));
65 $sectionField = new RefSField('section', array('u.section'), '', '', '');
66 $schoolField = new RefSField('school', array('edu.eduid'), 'profile_education', 'edu', 'u.user_id = edu.uid');
67 $diplomaField = new RefSField('diploma', array('edd.degreeid'), 'profile_education', 'edd', 'u.user_id = edd.uid');
eaf30d86 68
2398e553 69 $freeField = new RefSField('free', array('q.profile_freetext'), '', '', '', false);
eaf30d86 70
2398e553 71 $nwAddressField = new RefSField('networking_address', array('nw.address'), 'profile_networking', 'nw', 'nw.uid=u.user_id', false);
14256b08 72 if (Env::v('networking_address') == '') {
2398e553
SJ
73 $nwTypeField = new IndexSField('networking_type', array('nwe.network_type'), array('profile_networking', 'profile_networking_enum'),
74 array('nw', 'nwe'), array('nw.uid = u.user_id', 'nwe.network_type = nw.network_type'));
14256b08 75 } else {
2398e553
SJ
76 $nwTypeField = new IndexSField('networking_type',
77 array('nwe.network_type'), 'profile_networking_enum', 'nwe', 'nwe.network_type = nw.network_type');
14256b08 78 }
2398e553 79 $nwPhoneField = new PhoneSField('phone_number', array('t.search_tel'), 'profile_phones', 't', 't.uid = u.user_id');
eaf30d86 80 return array(
6443c93d 81 $nameField, $promo1Field,
14256b08 82 $promo2Field, $womanField, $subscriberField, $aliveField,
e4cd7a1f 83 $townField, $countryField, $regionField, $entrepriseField,
56670b6a 84 $posteField, $secteurField, $cvField, $natField, $binetField,
85 $groupexField, $sectionField, $schoolField, $diplomaField,
14256b08 86 $freeField, $fonctionField, $nwAddressField, $nwTypeField,
93f3f260 87 $nwPhoneField, $referentField);
56670b6a 88}
89
90// }}}
91
a7de4ef7 92// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 93?>