X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch%2Fclasses.inc.php;h=5c0307b113fcb543afbd2cb3a24e72b22d799a14;hb=043bbacf7d5ceaeba4db582ac0ea7c75d6f13c80;hp=5f01c97c35af1a32778618594e82bd3f62429511;hpb=d4775fe2dea4db5e6ca3db4a6034bb03a8b711cc;p=platal.git diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index 5f01c97..5c0307b 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -30,41 +30,61 @@ u.perms != \'pending\' AS wasinscrit, FIND_IN_SET(\'femme\', u.flags) AS sexe, a.alias AS forlife, - ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type, - ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type, + ede0.name AS eduname0, ede0.url AS eduurl0, edd0.degree AS edudegree0, edu0.grad_year AS edugrad_year0, f0.field AS edufield0, + ede1.name AS eduname1, ede1.url AS eduurl1, edd1.degree AS edudegree1, edu1.grad_year AS edugrad_year1, f1.field AS edufield1, + ede2.name AS eduname2, ede2.url AS eduurl2, edd2.degree AS edudegree2, edu2.grad_year AS edugrad_year2, f2.field AS edufield2, + ede3.name AS eduname3, ede3.url AS eduurl3, edd3.degree AS edudegree3, edu3.grad_year AS edugrad_year3, f3.field AS edufield3, es.label AS secteur, ef.fonction_fr AS fonction, - IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166, + IF(n1.nat=\'\',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1, + IF(n2.nat=\'\',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2, + IF(n3.nat=\'\',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3, (COUNT(em.email) > 0 OR FIND_IN_SET("googleapps", u.mail_storage) > 0) AS actif,'; // hide private information if not logged if (S::logged()) $globals->search->result_fields .=' - q.profile_web AS web, - q.profile_mobile AS mobile, q.profile_freetext AS freetext, adr.city, gp.pays AS countrytxt, gr.name AS region, - e.entreprise,'; + e.entreprise, + nw.address AS networking_address, + nwe.name AS networking_name,'; else $globals->search->result_fields .=" - IF(q.profile_web_pub='public', q.profile_web, '') AS web, - IF(q.profile_mobile_pub='public', q.profile_mobile, '') AS mobile, IF(q.profile_freetext_pub='public', q.profile_freetext, '') AS freetext, IF(adr.pub='public', adr.city, '') AS city, IF(adr.pub='public', gp.pays, '') AS countrytxt, IF(adr.pub='public', gr.name, '') AS region, - IF(e.pub='public', e.entreprise, '') AS entreprise,"; + IF(e.pub='public', e.entreprise, '') AS entreprise, + IF(nw.pub='public', nw.address, '') AS networking_address, + IF(nw.pub='public', nwe.name, '') AS networking_name,"; @$globals->search->result_where_statement = ' - LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0) - LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid) - LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1) - LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid) - LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) - LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) - LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) - LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2) - LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut)) - LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) - LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) - LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')'; + LEFT JOIN profile_education AS edu0 ON (u.user_id = edu0.uid AND edu0.id = 0) + LEFT JOIN profile_education_enum AS ede0 ON (ede0.id = edu0.eduid) + LEFT JOIN profile_education_degree_enum AS edd0 ON (edd0.id = edu0.degreeid) + LEFT JOIN profile_education_field_enum AS f0 ON (f0.id = edu0.fieldid) + LEFT JOIN profile_education AS edu1 ON (u.user_id = edu1.uid AND edu1.id = 1) + LEFT JOIN profile_education_enum AS ede1 ON (ede1.id = edu1.eduid) + LEFT JOIN profile_education_degree_enum AS edd1 ON (edd1.id = edu1.degreeid) + LEFT JOIN profile_education_field_enum AS f1 ON (f1.id = edu1.fieldid) + LEFT JOIN profile_education AS edu2 ON (u.user_id = edu2.uid AND edu2.id = 2) + LEFT JOIN profile_education_enum AS ede2 ON (ede2.id = edu2.eduid) + LEFT JOIN profile_education_degree_enum AS edd2 ON (edd2.id = edu2.degreeid) + LEFT JOIN profile_education_field_enum AS f2 ON (f2.id = edu2.fieldid) + LEFT JOIN profile_education AS edu3 ON (u.user_id = edu3.uid AND edu3.id = 3) + LEFT JOIN profile_education_enum AS ede3 ON (ede3.id = edu3.eduid) + LEFT JOIN profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid) + LEFT JOIN profile_education_field_enum AS f3 ON (f3.id = edu3.fieldid) + LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) + LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) + LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) + LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2) + LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2) + LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2) + LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut)) + LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) + LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) + LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\') + LEFT JOIN profile_networking AS nw ON (nw.uid = u.user_id) + LEFT JOIN profile_networking_enum AS nwe ON (nwe.network_type = nw.network_type)'; // }}} // {{{ class ThrowError @@ -209,6 +229,8 @@ class QuickSearch extends SField /** stores admin searches */ var $email; var $ip; + /** stores phone number */ + var $phone; // }}} // {{{ constructor @@ -227,7 +249,7 @@ class QuickSearch extends SField function isempty() { - return empty($this->strings) && empty($this->ranges) && empty($this->email) && empty($this->ip); + return empty($this->strings) && empty($this->ranges) && empty($this->email) && empty($this->ip) && empty($this->phone); } // }}} @@ -265,6 +287,12 @@ class QuickSearch extends SField foreach ($ranges as $r) { if (preg_match('!^([<>]\d{4}|\d{4}(-\d{4})?)$!', $r)) $this->ranges[] = $r; } + + $t = preg_replace('!(\d{4}-\d{4}|>\d{4}|<\d{4})!', '', $s); + $t = preg_replace('![<>\- ]!', '', $t); + if (strlen($t) > 4) { + $this->phone = $t; + } } // }}} @@ -310,6 +338,11 @@ class QuickSearch extends SField $ip = ip_to_uint($this->ip); $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0"; } + if (!empty($this->phone)){ + require_once("profil.func.inc.php"); + $phone = format_phone_number($this->phone) . "%"; + $where[] = 't.search_tel LIKE ' . XDB::escape($phone); + } return join(" AND ", $where); } @@ -335,6 +368,13 @@ class QuickSearch extends SField if (!empty($this->ip)) { $join .= "INNER JOIN logger.sessions AS ls ON (ls.uid = u.user_id)\n"; } + if (!empty($this->phone)) { + if (!S::logged()) { + $join .= "INNER JOIN profile_phones AS t ON (t.uid = u.user_id AND t.pub = 'public')"; + } else { + $join .= "INNER JOIN profile_phones AS t ON (t.uid = u.user_id)"; + } + } return $join; } // }}} @@ -492,6 +532,39 @@ class RefSField extends SField // }}} // {{{ class RefSFieldMultipleTable +class PhoneSField extends RefSField +{ + function PhoneSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition) + { + $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true); + } + + function get_request() + { + require_once("profil.func.inc.php"); + $this->value = trim(Env::v($this->fieldFormName)); + $this->value = format_phone_number($this->value); + } + + function compare() + { + return " LIKE '" . addslashes($this->value) . "%'"; + } +} + +class IndexSField extends RefSField +{ + function IndexSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition) + { + $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true); + } + + function get_request() + { + $this->value = trim(Env::v($this->fieldFormName)); + } +} + class MapSField extends RefSField { var $mapId;