From 86b5c8f0b6c9c79b9fb115efca8e6d21b13ec219 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sun, 15 Apr 2007 17:58:44 +0000 Subject: [PATCH] Fix geoloc on advance search include/geoloc.inc.php | 13 ++++++++----- include/userset.inc.php | 18 +++++++++--------- modules/search.php | 2 +- modules/search/search.inc.php | 3 +-- templates/search/adv.form.tpl | 13 +------------ templates/search/adv.links.tpl | 4 ++-- 6 files changed, 22 insertions(+), 31 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1699 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/geoloc.inc.php | 13 ++++++++----- include/userset.inc.php | 18 +++++++++--------- modules/search.php | 2 +- modules/search/search.inc.php | 3 +-- templates/search/adv.form.tpl | 13 +------------ templates/search/adv.links.tpl | 4 ++-- 6 files changed, 22 insertions(+), 31 deletions(-) diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index 6a460bc..bb341fd 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -406,6 +406,7 @@ function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) $mapid); $fields = new SFieldGroup(true, $SFields); $where = $fields->get_where_statement(); + $joins = $fields->get_select_statement(); if ($where) { $where .= ' AND '; } @@ -414,7 +415,7 @@ function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) gc.name, COUNT(u.user_id) AS pop, SUM(u.promo % 2) AS yellow', - "{$fields->get_select_statement()} + "$joins LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)", $where . ($direct ? "gcim.infos = 'smallest'" : '1'), 'gc.id, gc.alias', @@ -483,14 +484,16 @@ function geoloc_getData_subcountries($mapid, $sin, $minentities) 'am.cityid = gcim.city_id', 'map.map_id = gcim.map_id')); $fields = new SFieldGroup(true, $SFields); + $where = $fields->get_where_statement(); + $joins = $fields->get_select_statement(); $countryres = $set->get('map.map_id AS id, COUNT(u.user_id) AS nbPop, SUM(u.promo % 2) AS yellow, COUNT(DISTINCT gcim.city_id) AS nbCities, SUM(IF(u.user_id IS NULL,0,am.glng)) AS lonPop, SUM(IF(u.user_id IS NULL, 0,am.glat)) AS latPop', - $fields->get_select_statement(), - $fields->get_where_statement(), + $joins, + $where, 'map.map_id', 'NULL'); @@ -503,7 +506,7 @@ function geoloc_getData_subcountries($mapid, $sin, $minentities) if ($maxpop < $c['nbPop']) $maxpop = $c['nbPop']; $c['xPop'] = geoloc_to_x($c['lonPop'], $c['latPop']); $c['yPop'] = geoloc_to_y($c['lonPop'], $c['latPop']); - $countries[$c['id']] = array_merge($countries[$c['id']], $c); + @$countries[$c['id']] = array_merge($countries[$c['id']], $c); $nbcities += $c['nbCities']; } @@ -511,7 +514,7 @@ function geoloc_getData_subcountries($mapid, $sin, $minentities) if ($nocity && $nbcities < $minentities){ foreach($countries as $i => $c) { $countries[$i]['nbPop'] = 0; - if ($c['nbCities'] > 0) { + if (@$c['nbCities'] > 0) { geoloc_getData_subcities($c['id'], $sin, $cities, false); } } diff --git a/include/userset.inc.php b/include/userset.inc.php index 48d5878..a76b7c1 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -57,6 +57,7 @@ class UserSet extends PlSet class SearchSet extends UserSet { + public $advanced = false; private $score = null; private $order = null; private $quick = false; @@ -90,8 +91,7 @@ class SearchSet extends UserSet new ThrowError('Recherche trop générale.'); } $this->score = $qSearch->get_score_statement(); - parent::__construct("{$fields->get_select_statement()} - {$globals->search->result_where_statement}", + parent::__construct("{$fields->get_select_statement()}", $fields->get_where_statement() . (S::logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : '')); @@ -102,11 +102,12 @@ class SearchSet extends UserSet private function getAdvanced() { global $globals; + $this->advanced = true; $fields = new SFieldGroup(true, advancedSearchFromInput()); if ($fields->too_large()) { new ThrowError('Recherche trop générale.'); } - parent::__construct($fields->get_select_statement() . ' ' . $globals->search->result_where_statement, + parent::__construct($fields->get_select_statement(), $fields->get_where_statement()); $this->order = implode(',',array_filter(array($fields->get_order_statement(), 'promo DESC, NomSortKey, prenom'))); @@ -179,8 +180,7 @@ class MinificheView extends MultipageView public function joins() { - return ($this->set instanceof SearchSet ? "" : - "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) + return "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) @@ -192,10 +192,10 @@ class MinificheView extends MultipageView 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') - ") . (S::logged() ? - "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" - : ""); + LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')" . + (S::logged() ? + "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" + : ""); } public function templateName() diff --git a/modules/search.php b/modules/search.php index ea8491a..5a64865 100644 --- a/modules/search.php +++ b/modules/search.php @@ -135,7 +135,7 @@ class SearchModule extends PLModule $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->apply('search/adv', $page, $action, $subaction); if ($subaction) { return; diff --git a/modules/search/search.inc.php b/modules/search/search.inc.php index eae0a04..d3edb4d 100644 --- a/modules/search/search.inc.php +++ b/modules/search/search.inc.php @@ -46,7 +46,6 @@ function advancedSearchFromInput() $cityIdField = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av')); $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('gcim.map_id'), array('adresses','geoloc_city_in_maps'), array('am','gcim'), array(getadr_join('am'), 'am.cityid = gcim.city_id')); $entrepriseField = new RefSField('entreprise',array('ee.entreprise'),'entreprises','ee','u.user_id=ee.uid',false); $posteField = new RefSField('poste',array('ep.poste'),'entreprises','ep','u.user_id=ep.uid', false); @@ -69,7 +68,7 @@ function advancedSearchFromInput() $townField, $countryField, $regionField, $entrepriseField, $posteField, $secteurField, $cvField, $natField, $binetField, $groupexField, $sectionField, $schoolField, $diplomaField, - $freeField, $fonctionField, $cityIdField, $mapField); + $freeField, $fonctionField, $cityIdField); } // }}} diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index b47a3dc..f412da6 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -27,14 +27,6 @@