la carte geoloc
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 3 Jun 2006 09:37:56 +0000 (09:37 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 3 Jun 2006 09:37:56 +0000 (09:37 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@283 839d8a87-29fc-0310-9880-83ba4fa771e5

21 files changed:
hooks/geoloc.inc.php [new file with mode: 0644]
htdocs/admin/geoloc_dynamap.php [new file with mode: 0644]
htdocs/advanced_search.php
htdocs/geoloc/dynamap.php [moved from htdocs/geoloc/globe.php with 71% similarity]
htdocs/geoloc/geolocInit.php [new file with mode: 0644]
htdocs/geoloc/getCityInfos.php [new file with mode: 0644]
htdocs/geoloc/getData.php [new file with mode: 0644]
htdocs/geoloc/icon.php [new file with mode: 0644]
htdocs/geoloc/index.php
include/geoloc.inc.php
include/search.inc.php
include/search/classes.inc.php
templates/admin/geoloc_dynamap.tpl [new file with mode: 0644]
templates/geoloc/geolocInit.tpl [new file with mode: 0644]
templates/geoloc/getCityInfos.tpl [new file with mode: 0644]
templates/geoloc/getData.tpl [new file with mode: 0644]
templates/geoloc/index.tpl
templates/search.adv.form.tpl
templates/search.tpl
upgrade/0.9.10/00_geoloc.sql [new file with mode: 0644]
upgrade/0.9.10/update.sh [new file with mode: 0755]

diff --git a/hooks/geoloc.inc.php b/hooks/geoloc.inc.php
new file mode 100644 (file)
index 0000000..0165c29
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+// {{{ config HOOK
+
+// {{{ class GeolocConfig
+
+class GeolocConfig
+{
+    var $webservice_url = '';
+}
+
+// }}}
+
+function geoloc_config()
+{
+    global $globals;
+    $globals->geoloc = new GeolocConfig;
+}
+
+// }}}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/htdocs/admin/geoloc_dynamap.php b/htdocs/admin/geoloc_dynamap.php
new file mode 100644 (file)
index 0000000..53dd692
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once("xorg.inc.php");
+new_admin_page('admin/geoloc_dynamap.tpl');
+
+if (Env::get('fix') == 'cities_not_on_map')
+{
+    require_once('geoloc.inc.php');
+    if (!fix_cities_not_on_map(100))
+        $page->trig("Impossible d'accéder au webservice");
+}
+
+if (Env::has('new_maps'))
+{
+       require_once('geoloc.inc.php');
+       if (!get_new_maps(Env::get('url')))
+               $page->trig("Impossible d'accéder aux nouvelles cartes");
+}
+
+$countMissing = $globals->xdb->query("SELECT COUNT(*) FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL");
+$page->assign("nb_cities_not_on_map", $countMissing->fetchOneCell());
+
+$page->run();
+
+// vim:set et sws=4 sts=4 sw=4:
+?>
+
index 9832e54..a935b64 100644 (file)
 
 require_once("xorg.inc.php");
 require_once('search.inc.php');
-new_skinned_page('search.tpl', AUTH_COOKIE);
-
+if (Env::get('display')!='mini')
+    new_skinned_page('search.tpl', AUTH_COOKIE);
+else
+    new_simple_page('search.tpl', AUTH_COOKIE);
 $page->assign('advanced',1);
 $page->assign('public_directory',0);
 require_once("applis.func.inc.php");
@@ -64,59 +66,18 @@ if (!Env::has('rechercher')) {
     form_prepare();
 } else {
 
-    // {{{ function get_list()
+// {{{ function get_list()
 
     function get_list($offset, $limit, $order) {
-        if ($with_soundex = Env::has('with_soundex')) {
-            $nameField      = new RefWithSoundexSField('name',array('rn.nom1_soundex','rn.nom2_soundex','rn.nom3_soundex'),'recherche_soundex','rn','u.matricule = rn.matricule');
-            $firstnameField = new RefWithSoundexSField('firstname',array('rp.prenom1_soundex','rp.prenom2_soundex'),'recherche_soundex','rp','u.matricule = rp.matricule');
-        } else {
-            $nameField      = new NameSField('name',array('u.nom','u.nom_usage'),'');
-            $firstnameField = new StringSField('firstname',array('u.prenom'),'');
-        }
-        $nicknameField   = new StringSField('nickname',array('q.profile_nick'),'');
-        
-        $promo1Field     = new PromoSField('promo1','egal1',array('u.promo'),'');
-        $promo2Field     = new PromoSField('promo2','egal2',array('u.promo'),'');
-        $womanField      = new RefSField('woman',array('FIND_IN_SET(u.flags,\'femme\')+1'),'','','');
-        $subscriberField = new RefSField('subscriber',array('!(u.perms IN (\'admin\',\'user\'))+1'),'','','');
-        $aliveField      = new RefSField('alive',array('(u.deces!=0)+1'),'','','');
-       
-        $townField       = new RefSField('city',array('av.city'),'adresses','av','u.user_id=av.uid',false);
-        $countryField    = new RefSField('country',array('ap.country'),'adresses','ap','u.user_id=ap.uid');
-        $regionField     = new RefSField('region',array('ar.region'),'adresses','ar','u.user_id=ar.uid');
-       
-        $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);
-        $fonctionField   = new RefSField('fonction',array('en.fonction'),'entreprises','en','u.user_id=en.uid');
-        $secteurField    = new RefSField('secteur',array('fm.secteur'),'entreprises','fm','u.user_id=fm.uid');
-        $cvField         = new RefSField('cv',array('u.cv'),'','','',false);
-       
-        $natField        = new RefSField('nationalite',array('u.nationalite'),'','','');
-        $binetField      = new RefSField('binet',array('b.binet_id'),'binets_ins','b','u.user_id=b.user_id');
-        $groupexField    = new RefSField('groupex',array('g.gid'),'groupesx_ins','g','u.user_id=g.guid');
-        $sectionField    = new RefSField('section',array('u.section'),'','','');
-        $schoolField     = new RefSField('school',array('as.aid'),'applis_ins','`as`','u.user_id=as.uid');
-        $diplomaField    = new RefSField('diploma',array('ad.type'),'applis_ins','ad','u.user_id=ad.uid');
-      
-        $freeField       = new RefSField('free',array('q.profile_freetext'),'','','',false);
-      
-        $fields          = new SFieldGroup(true, array( 
-                    $nameField, $firstnameField, $nicknameField, $promo1Field,
-                    $promo2Field, $womanField, $subscriberField, $aliveField,
-                    $townField, $countryField, $regionField, $entrepriseField,
-                    $posteField, $secteurField, $cvField, $natField, $binetField,
-                    $groupexField, $sectionField, $schoolField, $diplomaField,
-                    $freeField, $fonctionField)
-                );
-
-    
+        $fields = new SFieldGroup(true, advancedSearchFromInput());
         if ($fields->too_large()) {
             form_prepare();
             new ThrowError('Recherche trop générale.');
         }
-        global $globals;
-    
+        global $globals, $page;
+  
+                       $page->assign('search_vars', $fields->get_url());
+                       
         $where = $fields->get_where_statement();
         if ($where) {
             $where = "WHERE  $where";
@@ -144,7 +105,7 @@ if (!Env::has('rechercher')) {
         return Array($liste, $nb_tot);
     }
 
-    // }}}
+// }}}
 
     $search = new XOrgSearch('get_list');
     $search->setNbLines($globals->search->per_page);
similarity index 71%
rename from htdocs/geoloc/globe.php
rename to htdocs/geoloc/dynamap.php
index a8b32d0..1d3ecc5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2005 Polytechnique.org                              *
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+
 require_once('xorg.inc.php');
+
 new_nonhtml_page('', AUTH_COOKIE);
-header("Content-type: image/png");
 
-$res = $globals->xdb->iterRow('SELECT lat, lon FROM geoloc_city AS gc LEFT JOIN adresses AS a ON(gc.id = a.cityid) WHERE a.cityid IS NOT NULL GROUP BY gc.id');
+$querystring = "";
+foreach ($_GET as $v => $a)
+       if ($v != 'initfile')
+               $querystring .= '&'.urlencode($v).'='.urlencode($a);
+$initfile = urlencode('geolocInit.php?'.$querystring);
 
-$img = imageCreateFromPng("../images/globe.png");
+if (urlencode(Env::get('initfile')) != $initfile)
+{
+       header("Location: dynamap.php?initfile=$initfile{$querystring}");
+       die();
+}
 
-$coul = imagecolorallocate($img, 0, 0, 0);
+header("Content-type: application/x-shockwave-flash");
 
-while ($a = $res->next()) {
-    $x = floor(($a[1]/100000 + 180 )/360*600);
-    $y = floor((90 - $a[0]/100000)/180*300);
-    imagefilledrectangle($img, $x, $y, $x+1, $y+1, $coul);
-}
+readfile("../../plugins/geoloc/dynamap.swf");
 
-imagePng($img);
-imagedestroy($img);
-// vim:set et sws=4 sw=4 sts=4:
 ?>
diff --git a/htdocs/geoloc/geolocInit.php b/htdocs/geoloc/geolocInit.php
new file mode 100644 (file)
index 0000000..6ecc2ca
--- /dev/null
@@ -0,0 +1,13 @@
+<?php 
+require_once('xorg.inc.php');
+
+header("Content-type: text/xml");
+new_nonhtml_page('geoloc/geolocInit.tpl', AUTH_COOKIE);
+
+$querystring = "";
+foreach ($_GET as $v => $a)
+       if ($v != 'initfile')
+               $querystring .= '&'.urlencode($v).'='.urlencode($a);
+$page->assign('querystring',$querystring);
+$page->run();
+?>
diff --git a/htdocs/geoloc/getCityInfos.php b/htdocs/geoloc/getCityInfos.php
new file mode 100644 (file)
index 0000000..45fbf0b
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+
+require_once('xorg.inc.php');
+
+header("Content-type: text/xml");
+
+new_nonhtml_page('geoloc/getCityInfos.tpl', AUTH_COOKIE);
+// to debug sql use the next line
+//new_skinned_page('', AUTH_COOKIE);
+
+require_once('geoloc.inc.php');
+require_once('search.inc.php');
+
+$usual_fields = advancedSearchFromInput();
+$fields = new SFieldGroup(true, $usual_fields);
+$where = $fields->get_where_statement();
+if ($where) $where = "WHERE ".$where;
+
+$users = $globals->xdb->iterator("
+    SELECT u.user_id AS id, u.prenom, u.nom, u.promo
+      FROM adresses AS a 
+INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid)
+INNER JOIN auth_user_quick AS q ON(q.user_id = a.uid)
+        ".$fields->get_select_statement()."
+        ".$where."
+     GROUP BY u.user_id LIMIT 11",
+        $id);
+
+$page->assign('users', $users);
+
+$page->run();
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/htdocs/geoloc/getData.php b/htdocs/geoloc/getData.php
new file mode 100644 (file)
index 0000000..61b6f9c
--- /dev/null
@@ -0,0 +1,163 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+
+require_once('xorg.inc.php');
+
+// to debug sql use the next line
+if (Env::has('debug'))
+       new_simple_page('geoloc/getData.tpl', AUTH_COOKIE);
+else
+{
+       header("Content-type: text/xml");
+       new_nonhtml_page('geoloc/getData.tpl', AUTH_COOKIE);
+}
+
+require_once('search.inc.php');
+require_once('geoloc.inc.php');
+
+$usual_fields = advancedSearchFromInput();
+foreach ($usual_fields as $i_mapfield => $field) if ($field->fieldFormName == 'mapid') break;
+
+$querystring = "";
+foreach ($_GET as $v => $a)
+       if ($v != 'mapid')
+               $querystring .= urlencode($v).'='.urlencode($a).'&amp;';
+$page->assign('searchvars', $querystring);
+
+$maxentities = 100;
+$minentities = 5;
+
+function get_cities_in_territory($t, $usual_fields, $direct=true)
+{
+  global $cities, $globals, $i_mapfield;
+  $usual_fields[$i_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'), $t);
+               $fields = new SFieldGroup(true, $usual_fields);
+               $where = $fields->get_where_statement();
+               if ($where) $where = " AND ".$where;
+    $cityres = $globals->xdb->iterator("
+        SELECT  gc.id,
+                gc.lon / 100000 AS x, gc.lat/100000 AS y,
+                gc.name,
+                COUNT(u.user_id) AS pop,
+                SUM(u.promo % 2) AS yellow
+          FROM auth_user_md5 AS u
+    INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
+            ".$fields->get_select_statement()."
+                                LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)
+         WHERE ".($direct?"gcim.infos = 'smallest'":"1")."
+         $where
+      GROUP BY gc.id,gc.alias ORDER BY pop DESC");
+    while ($c = $cityres->next())
+        if ($c['pop'] > 0)
+        {
+            $city = $c;
+            $city['x'] = geoloc_to_x($c['x'], $c['y']);
+            $city['y'] = geoloc_to_y($c['x'], $c['y']);
+            $city['size'] = size_of_city($c['pop']);
+            $cities[$c['id']] = $city;
+        }
+}
+
+if (Env::has('mapid'))
+       $wheremapid = "WHERE   gm.parent = {?}";
+else
+       $wheremapid = "WHERE gm.parent IS NULL";
+
+$submapres = $globals->xdb->iterator(
+    "SELECT  gm.map_id AS id, gm.name, gm.x, gm.y, gm.xclip, gm.yclip, 
+            gm.width, gm.height, gm.scale, 1 AS rat
+    FROM    geoloc_maps AS gm
+    ".$wheremapid, Env::get('mapid',''));
+
+$countries = array();
+while ($c = $submapres->next())
+{
+    $country = $c;
+    $country['name'] = utf8_decode($country['name']);
+    $country['color'] = 0xFFFFFF;
+    $country['swf'] = $globals->geoloc->webservice_url."maps/mercator/map_".$c['id'].".swf";
+    $countries[$c['id']] = $country;
+}
+
+$cities = array();
+if (Env::has('mapid'))
+{
+       get_cities_in_territory(Env::getInt('mapid'), $usual_fields);
+       $nbcities = count($cities);
+       $nocity = $nbcities == 0;
+
+       $usual_fields[$i_mapfield] = new MapSField('mapid', array('map.parent'), array('adresses','geoloc_city_in_maps','geoloc_maps'), array('am','gcim','map'), array(getadr_join('am'), 'am.cityid = gcim.city_id', 'map.map_id = gcim.map_id'));
+       $fields = new SFieldGroup(true, $usual_fields);
+       $where = $fields->get_where_statement();
+       if ($where) $where = " WHERE ".$where;
+               
+       $countryres = $globals->xdb->iterator("
+           SELECT  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
+             FROM  auth_user_md5 AS u
+       INNER JOIN  auth_user_quick AS q ON(u.user_id = q.user_id)
+                   ".$fields->get_select_statement()."
+            $where
+         GROUP BY  map.map_id ORDER BY NULL", $hierarchy);
+       
+       $maxpop = 0;
+       $nbentities = $nbcities + $countryres->total();
+       while ($c = $countryres->next())
+       {
+           $c['latPop'] /= $c['nbPop'];
+           $c['lonPop'] /= $c['nbPop'];
+           $c['rad'] = size_of_territory($c['nbPop']);
+           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);
+       
+           $nbcities += $c['nbCities'];
+       }
+       
+       if ($nocity && $nbcities < 10)
+       {
+           foreach($countries as $i => $c)
+           {
+               $countries[$i]['nbPop'] = 0;
+               if ($c['nbCities'] > 0)
+                   get_cities_in_territory($c['id'], $usual_fields, false);
+           }   
+       }
+       
+       foreach ($countries as $i => $c) if ($c['nbPop'] > 0)
+       {
+           $lambda = pow($c['nbPop'] / $maxpop,0.3);
+           $countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
+       }
+}
+
+$page->assign('countries', $countries);
+$page->assign('cities', $cities);
+
+$page->run();
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/htdocs/geoloc/icon.php b/htdocs/geoloc/icon.php
new file mode 100644 (file)
index 0000000..7482ffc
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+
+require_once('xorg.inc.php');
+
+new_nonhtml_page('', AUTH_COOKIE);
+
+header("Content-type: application/x-shockwave-flash");
+
+readfile("../../plugins/geoloc/icon.swf");
+
+?>
index ad1da96..5b3d7b5 100644 (file)
@@ -25,6 +25,14 @@ new_skinned_page('geoloc/index.tpl', AUTH_COOKIE);
 $res = $globals->xdb->query('SELECT COUNT(DISTINCT uid) FROM adresses WHERE cityid IS NOT NULL');
 $page->assign('localises', $res->fetchOneCell());
 
+       require_once('search.inc.php');
+$fields = new SFieldGroup(true, advancedSearchFromInput());
+$search = $fields->get_url().'&amp;';
+if (Env::has('only_current') && Env::get('only_current') != 'on') $search .= '&only_current=';
+$search = preg_replace('/(^|&amp;)mapid=([0-9]+)(&amp;|$)/','\1\3', $search);
+if ($search)
+       $page->assign('dynamap_vars', $search);
+
 $page->run();
 
 // vim:set et sws=4 sw=4 sts=4:
index d77668a..3ef6611 100644 (file)
@@ -73,13 +73,13 @@ $GLOBALS['page']->register_function('geoloc_region', '_geoloc_region_smarty');
  * @param $txt the raw text of an address
  */
 function get_address_infos($txt) {
-    $url ="http://www.geoloc.org/adressparser/address.php?txt=".urlencode(utf8_encode($txt));
+    global $globals;
+    $url = $globals->geoloc->webservice_url."address.php?txt=".urlencode(utf8_encode($txt)."&precise=1");
     if (!($f = @fopen($url, 'r'))) return false;
     $keys = explode('|',fgets($f));
     $vals = explode('|',fgets($f));
     $infos = array();
     foreach ($keys as $i=>$key) if($vals[$i]) $infos[$key] = ($key == 'sql')?$vals[$i]:utf8_decode(strtr($vals[$i], array(chr(197).chr(147) => "&oelig;")));
-    global $globals;
     if ($infos['sql'])
        $globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']);
     if ($infos['display'])
@@ -88,6 +88,44 @@ function get_address_infos($txt) {
 }
 // }}}
 
+// {{{ get_cities_maps($array)
+/* get all the maps id of the cities contained in an array */
+function get_cities_maps($array)
+{
+    global $globals;
+    implode("\n",$array);
+    $url = $globals->geoloc->webservice_url."findMaps.php?datatext=".urlencode(utf8_encode(implode("\n", $array)));
+    if (!($f = @fopen($url, 'r'))) return false;
+    $maps = array();
+    while (!feof($f))
+    {
+        $l = trim(fgets($f));
+        $tab = explode(';', $l);
+        $i = $tab[0];
+        unset($tab[0]);
+        $maps[$i] = $tab;
+    }
+    return $maps;
+}
+// }}}
+
+// {{{ get_new_maps($url)
+/** set new maps from url **/
+function get_new_maps($url)
+{
+       if (!($f = @fopen($url, 'r'))) return false;
+       global $globals;
+       $globals->xdb->query('TRUNCATE TABLE geoloc_maps');
+       $s = '';
+  while (!feof($f)) {
+       $l = fgetcsv($f, 1024, ';', '"');
+       foreach ($l as $i => $val) if ($val != 'NULL') $l[$i] = '\''.addslashes($val).'\'';
+       $s .= ',('.implode(',',$l).')';
+  }
+       $globals->xdb->execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1));
+       return true;
+}
+
 // {{{ get_address_text($adr)
 /** make the text of an address that can be read by a mailman
  * @param $adr an array with all the usual fields
@@ -186,11 +224,13 @@ function localize_addresses($uid) {
             $globals->xdb->execute("UPDATE adresses SET
                 adr1 = {?}, adr2 = {?}, adr3 = {?},
                 cityid = {?}, city = {?}, postcode = {?},
-                region = {?}, regiontxt = {?}, country = {?}
+                region = {?}, regiontxt = {?}, country = {?},
+                glat = {?}, glng = {?}
                 WHERE uid = {?} AND adrid = {?}",
                 $new['adr1'], $new['adr2'], $new['adr3'],
                 $new['cityid'], $new['city'], $new['postcode'],
                 $new['region'], $new['regiontxt'], $new['country'],
+                $new['precise_lat'], $new['precise_lon'],
                 $uid, $a['adrid']);
                 $new['store'] = true;
                 if (!$new['cityid']) $erreur[$a['adrid']] = $new;
@@ -208,14 +248,58 @@ function localize_addresses($uid) {
  * @param $id the id of the city to synchronize
  */
  function synchro_city($id) {
-    $url ="http://www.geoloc.org/adressparser/cityFinder.php?method=id&id=".$id."&out=sql";
+    global $globals;
+    $url = $globals->geoloc->webservice_url."cityFinder.php?method=id&id=".$id."&out=sql";
     if (!($f = @fopen($url, 'r'))) return false;
     $s = fgets($f);
-    global $globals;
     if ($s)
         return $globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$s) > 0;
  }
  // }}}
 
+// {{{ function fix_cities_not_on_map($limit)
+function fix_cities_not_on_map($limit=false)
+{
+    global $globals;
+    $missing = $globals->xdb->query("SELECT c.id FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL".($limit?" LIMIT $limit":""));
+    $maps = get_cities_maps($missing->fetchColumn());
+    if ($maps)
+    {
+        $values = "";
+        foreach ($maps as $cityid => $maps_c)
+            foreach ($maps_c as $map_id)
+                $values .= ",($cityid, $map_id, '')";
+        $globals->xdb->execute("REPLACE INTO geoloc_city_in_maps VALUES ".substr($values, 1));
+    }
+    else
+        return false;
+
+    $maxlevelquery = $globals->xdb->query("SELECT MAX(level) FROM geoloc_maps");
+    $maxlevel = $maxlevelquery->fetchOneCell();
+    for ($level = $maxlevel; $level >= 0; $level--)
+        $globals->xdb->query("
+            UPDATE geoloc_city AS gc
+        INNER JOIN geoloc_city_in_maps AS gcim ON(gc.id = gcim.city_id)
+        INNER JOIN geoloc_maps AS gm ON(gm.id = gcim.map_id AND gm.level = {?})
+         LEFT JOIN geoloc_city_in_maps AS gcim2 ON(gc.id = gcim2.city_id AND gcim2.infos = 'smallest')
+               SET gcim.infos = 'smallest'
+             WHERE gcim2.city_id IS NULL", $level);
+
+    return true;
+}
+// }}}
+
+
+function geoloc_to_x($lon, $lat) { return deg2rad(1) * $lon *100; }
+
+function geoloc_to_y($lon, $lat) {
+       if ($lat < -75) return latToY(-75);
+       if ($lat > 75) return latToY(75);
+  return -100 * log(tan(pi()/4 + deg2rad(1)/2*$lat));  
+}
+
+function size_of_city($nb) { $s = round(log($nb + 1)*2,2); if ($s < 1) return 1; return $s; }
+function size_of_territory($nb) { return size_of_city($nb); }
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index d40856b..a337031 100644 (file)
 require_once('xorg.plugin.inc.php');
 require_once("search/classes.inc.php");
 
+// {{{ function advancedSearchFromInput
+function advancedSearchFromInput()
+{
+    if ($with_soundex = Env::has('with_soundex')) {
+        $nameField      = new RefWithSoundexSField('name',array('rn.nom1_soundex','rn.nom2_soundex','rn.nom3_soundex'),'recherche_soundex','rn','u.matricule = rn.matricule');
+        $firstnameField = new RefWithSoundexSField('firstname',array('rp.prenom1_soundex','rp.prenom2_soundex'),'recherche_soundex','rp','u.matricule = rp.matricule');
+    } else {
+        $nameField      = new NameSField('name',array('u.nom','u.nom_usage'),'');
+        $firstnameField = new StringSField('firstname',array('u.prenom'),'');
+    }
+    $nicknameField   = new StringSField('nickname',array('q.profile_nick'),'');
+    
+    $promo1Field     = new PromoSField('promo1','egal1',array('u.promo'),'');
+    $promo2Field     = new PromoSField('promo2','egal2',array('u.promo'),'');
+    $womanField      = new RefSField('woman',array('FIND_IN_SET(u.flags,\'femme\')+1'),'','','');
+    $subscriberField = new RefSField('subscriber',array('!(u.perms IN (\'admin\',\'user\'))+1'),'','','');
+    $aliveField      = new RefSField('alive',array('(u.deces!=0)+1'),'','','');
+
+    function getadr_join($table) {
+        return 'u.user_id='.$table.'.uid'.(Env::get('only_current',false)?' AND FIND_IN_SET(\'active\','.$table.'.statut)':'');
+    }
+
+    $townField      = new RefSField('city',array('ac.city'),'adresses','ac',getadr_join('ac'),false);
+    $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);
+    $fonctionField   = new RefSField('fonction',array('en.fonction'),'entreprises','en','u.user_id=en.uid');
+    $secteurField    = new RefSField('secteur',array('fm.secteur'),'entreprises','fm','u.user_id=fm.uid');
+    $cvField         = new RefSField('cv',array('u.cv'),'','','',false);
+   
+    $natField        = new RefSField('nationalite',array('u.nationalite'),'','','');
+    $binetField      = new RefSField('binet',array('b.binet_id'),'binets_ins','b','u.user_id=b.user_id');
+    $groupexField    = new RefSField('groupex',array('g.gid'),'groupesx_ins','g','u.user_id=g.guid');
+    $sectionField    = new RefSField('section',array('u.section'),'','','');
+    $schoolField     = new RefSField('school',array('as.aid'),'applis_ins','`as`','u.user_id=as.uid');
+    $diplomaField    = new RefSField('diploma',array('ad.type'),'applis_ins','ad','u.user_id=ad.uid');
+  
+    $freeField       = new RefSField('free',array('q.profile_freetext'),'','','',false);
+  
+    return array( 
+                $nameField, $firstnameField, $nicknameField, $promo1Field,
+                $promo2Field, $womanField, $subscriberField, $aliveField,
+                $townField, $countryField, $regionField, $entrepriseField,
+                $posteField, $secteurField, $cvField, $natField, $binetField,
+                $groupexField, $sectionField, $schoolField, $diplomaField,
+                $freeField, $fonctionField, $cityIdField, $mapField);
+}
+
+// }}}
+
 // {{{ class XOrgSearch
 
 class XOrgSearch extends XOrgPlugin
index 4b5718a..ce6fad3 100644 (file)
@@ -439,6 +439,36 @@ class RefSField extends SField
 }
 
 // }}}
+
+// {{{ class RefSFieldMultipleTable
+class MapSField extends RefSField
+{
+       var $mapId;
+       
+    function MapSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition, $_mapId=false)
+    {
+       if ($_mapId === false)
+               $this->mapId = Env::get($_fieldFormName);
+                       else
+                               $this->mapId = $_mapId;
+       $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true, false);
+    }
+    function get_select_statement()
+    {
+        $res = implode(' OR ', array_filter(array_map(array($this, 'get_single_match_statement'), $this->fieldDbName)));
+        foreach ($this->refTable as $i => $refT)
+            $last = $i;
+        $inner = "";
+        foreach ($this->refTable as $i => $refT)
+            $inner .= " INNER JOIN {$refT} AS {$this->refAlias[$i]} ON ({$this->refCondition[$i]} ".(($i == $last)?"AND ($res) ":"").")";
+        return $inner;
+    }
+    function get_request()
+    {
+       $this->value = $this->mapId;
+    }
+}
+
 // {{{ class RefWithSoundexSField                       [ ??? ]
 
 class RefWithSoundexSField extends RefSField
@@ -777,4 +807,5 @@ class SFieldGroup
 
 // }}}
 
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
diff --git a/templates/admin/geoloc_dynamap.tpl b/templates/admin/geoloc_dynamap.tpl
new file mode 100644 (file)
index 0000000..0d37d23
--- /dev/null
@@ -0,0 +1,49 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>
+  Administration de la dynamap
+</h1>
+
+<h2>
+  Utiliser de nouvelles cartes
+</h2>
+  <form action='' method='post'>
+    <p>
+      <input type='text' name='url' value='{$smarty.request.url|default:"url des données des cartes"}' onfocus='select()' size='40'/>
+         <br/>
+      <input type='submit' name='new_maps'/>
+    </p>
+  </form>
+  
+<h2>
+  Placement des villes sur les cartes
+</h2>
+{if $nb_cities_not_on_map}
+  <p>
+    Il y a {$nb_cities_not_on_map} villes qui ne sont pas placées dans les cartes. [<a href='?fix=cities_not_on_map'>Réparer</a>]
+  </p>
+{else}
+  <p> Toutes les villes de la base sont placées dans des cartes. </p>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/geoloc/geolocInit.tpl b/templates/geoloc/geolocInit.tpl
new file mode 100644 (file)
index 0000000..5f30813
--- /dev/null
@@ -0,0 +1,43 @@
+{**************************************************************************}\r
+{*                                                                        *}\r
+{*  Copyright (C) 2003-2006 Polytechnique.org                             *}\r
+{*  http://opensource.polytechnique.org/                                  *}\r
+{*                                                                        *}\r
+{*  This program is free software; you can redistribute it and/or modify  *}\r
+{*  it under the terms of the GNU General Public License as published by  *}\r
+{*  the Free Software Foundation; either version 2 of the License, or     *}\r
+{*  (at your option) any later version.                                   *}\r
+{*                                                                        *}\r
+{*  This program is distributed in the hope that it will be useful,       *}\r
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}\r
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}\r
+{*  GNU General Public License for more details.                          *}\r
+{*                                                                        *}\r
+{*  You should have received a copy of the GNU General Public License     *}\r
+{*  along with this program; if not, write to the Free Software           *}\r
+{*  Foundation, Inc.,                                                     *}\r
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}\r
+{*                                                                        *}\r
+{**************************************************************************}\r
+<config\r
+grandOncleVisibility="-1"\r
+tooltipSize="0"\r
+tooltipDX="0"\r
+tooltipDY="20"\r
+panelSize="28"\r
+citySize="6"\r
+radius100="1.6"\r
+radius0="3"\r
+select="aim"\r
+aimTween="5"\r
+transition="2"\r
+textLookInCity="Rechercher les x dans cette ville"\r
+textZoomIn="Zoom"\r
+textGoTo="Va a "\r
+textZoomBackTo="Reviens a "\r
+textLoading="Chargement"\r
+textYouAreIn="Tu es dans "\r
+textSeeMapOfCity="Voir la carte de "\r
+textYouHaveSelected="Tu as selectionne "\r
+textCopyright="Les regles de l'annuaire s'appliquent aussi a cette application"\r
+scriptInfosArea="getData.php?{$querystring}"/>\r
diff --git a/templates/geoloc/getCityInfos.tpl b/templates/geoloc/getCityInfos.tpl
new file mode 100644 (file)
index 0000000..e2488c7
--- /dev/null
@@ -0,0 +1,27 @@
+{**************************************************************************}\r
+{*                                                                        *}\r
+{*  Copyright (C) 2003-2004 Polytechnique.org                             *}\r
+{*  http://opensource.polytechnique.org/                                  *}\r
+{*                                                                        *}\r
+{*  This program is free software; you can redistribute it and/or modify  *}\r
+{*  it under the terms of the GNU General Public License as published by  *}\r
+{*  the Free Software Foundation; either version 2 of the License, or     *}\r
+{*  (at your option) any later version.                                   *}\r
+{*                                                                        *}\r
+{*  This program is distributed in the hope that it will be useful,       *}\r
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}\r
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}\r
+{*  GNU General Public License for more details.                          *}\r
+{*                                                                        *}\r
+{*  You should have received a copy of the GNU General Public License     *}\r
+{*  along with this program; if not, write to the Free Software           *}\r
+{*  Foundation, Inc.,                                                     *}\r
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}\r
+{*                                                                        *}\r
+<?xml version="1.0" encoding="utf-8"?>\r
+<city id="{$smarty.request.cityid}">\r
+  {assign var="beginning" value=true}\r
+  {assign var="nb_displayed" value=0}\r
+  {iterate from=$users item="user"}{if !$beginning}<br/>{/if}{if $nb_displayed < 10}<a href="javascript:ficheXorg({$user.id});">{$user.prenom|utf8_encode} {$user.nom|strtolower|ucwords|utf8_encode} - {$user.promo}</a>{else}<a href="javascript:clickOnCity({$smarty.request.cityid})">...</a>{/if}{assign var="nb_displayed" value=$nb_displayed+1}{assign var="beginning" value=false}{/iterate}\r
+</city>\r
+{* vim:set et sw=2 sts=2 sws=2: *}\r
diff --git a/templates/geoloc/getData.tpl b/templates/geoloc/getData.tpl
new file mode 100644 (file)
index 0000000..81a1918
--- /dev/null
@@ -0,0 +1,47 @@
+{**************************************************************************}\r
+{*                                                                        *}\r
+{*  Copyright (C) 2003-2006 Polytechnique.org                             *}\r
+{*  http://opensource.polytechnique.org/                                  *}\r
+{*                                                                        *}\r
+{*  This program is free software; you can redistribute it and/or modify  *}\r
+{*  it under the terms of the GNU General Public License as published by  *}\r
+{*  the Free Software Foundation; either version 2 of the License, or     *}\r
+{*  (at your option) any later version.                                   *}\r
+{*                                                                        *}\r
+{*  This program is distributed in the hope that it will be useful,       *}\r
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}\r
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}\r
+{*  GNU General Public License for more details.                          *}\r
+{*                                                                        *}\r
+{*  You should have received a copy of the GNU General Public License     *}\r
+{*  along with this program; if not, write to the Free Software           *}\r
+{*  Foundation, Inc.,                                                     *}\r
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}\r
+{*                                                                        *}\r
+{**************************************************************************}\r
+<?xml version="1.0" encoding="utf-8"?>\r
+<country id="{$smarty.request.mapid}">\r
+  <countries>\r
+    {foreach from=$countries item="country"}\r
+    <country id="{$country.id}" name="{$country.name|utf8_encode}">\r
+      <file swf="{$country.swf}" scale="{$country.scale}" xclip="{$country.xclip}" yclip="{$country.yclip}">\r
+        <color value="{$country.color}"/>\r
+      </file>\r
+      {if $country.nbPop > 0 or $country.id eq 0}\r
+      <map x="{$country.x}" y="{$country.y}" height="{$country.height}" width="{$country.width}" ratio="{$country.rat}"/>\r
+      <icon x="{$country.xPop}" y="{$country.yPop}" nb="{$country.nbPop}" size="{$country.rad}" name="{$country.name|utf8_encode}" yellow="{$country.yellow}"/>\r
+      <moreinfos url="getData.php?{$searchvars}mapid={$country.id}"/>\r
+      {/if}\r
+    </country>\r
+    {/foreach}\r
+  </countries>\r
+  <cities>\r
+    {foreach from=$cities item="city"}\r
+    <city id="{$city.id}" name="{$city.name}">\r
+      <icon x="{$city.x}" y="{$city.y}" nb="{$city.pop}" size="{$city.size}" name="{$city.name}" yellow="{$city.yellow}"/>\r
+      <moreinfos url="getCityInfos.php?{$searchvars}cityid={$city.id}"/>\r
+    </city>\r
+    {/foreach}\r
+  </cities>\r
+</country>\r
+{* vim:set et sw=2 sts=2 sws=2: *}\r
index 9bd44ee..0bc0b80 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2004 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2006 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 
 <h1>Géolocalisation</h1>
 
-<p class="descr">Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles. La géolocalisation permet de :
-</p>
-<ul>
-<li>standardiser les adresses</li>
-<li>rechercher de manière précise par lieu géographique</li>
-<li>dans un deuxième temps, faire des jolies cartes</li>
-</ul>
+<script type="text/javascript">
+{literal}
+function ficheXorg(id)
+{
+  window.open('../fiche.php?user='+id,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=840,height=600');
+}
+function clickOnCity(id)
+{
+       var f = document.getElementById('search_form');
+       var url = f.action;
+       f.action += '&cityid=' + id; 
+       f.submit();
+       f.action = url;
+       document.getElementById('search_results').style.height = '250px';
+}
+var mapid = 0;
+function goToCountry(id)
+{
+       mapid = id;
+}
+function searchMapId(f)
+{
+       var url = f.action;
+       f.action += '&mapid=' + mapid; 
+       f.submit();
+       f.action = url;
+       document.getElementById('search_results').style.height = '250px';
+}
+{/literal}
 
+</script>
+{if !$dynamap_vars}
+<p class="descr">
+Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles.
+</p>
+{/if}
 <p class="center">
-<img src="globe.php" alt="Carte du monde des X"/>
+<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="450" id="dynamap" align="middle">
+<param name="allowScriptAccess" value="sameDomain" />
+<param name="quality" value="high" />
+<param name="bgcolor" value="#ffffff" />
+<param name="movie" value="dynamap{$dynamap_vars|default:"only_current=on"}.swf" />
+<embed src="dynamap{$dynamap_vars|default:"only_current=on"}.swf" quality="high" bgcolor="#ffffff" width="600" height="450" name="dynamap" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
+</object>
 </p>
-
-<p class="descr">Pour savoir comment ça marche tu peux aller faire un tour sur le <a href="http://www.aaege.org/GeolocDev/">site de développement</a> du projet.</p>
-
+<form id="search_form" action="{#globals.baseurl#}/advanced_search.php?{$dynamap_vars|default:"only_current=on"}&amp;rechercher=1" method="post">
+<p>
+       <input type="button" value="Lister les camarades de la carte" onclick="searchMapId(this.form)"/>
+</p>
+</form>
 <p class="descr">Pour toute question, problème ou suggestion tu peux envoyer un mail à <a href="mailto:contact+geoloc@polytechnique.org">contact+geoloc@polytechnique.org</a></p>
 
 {* vim:set et sw=2 sts=2 sws=2: *}
index 4f9562e..2bfff6d 100644 (file)
       <th colspan="2">Géographie</th>
     </tr>
     <tr>
+      <td colspan="2">
+      <label for="only_current"><input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current} checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont actuellement.</label></td>
+    </tr>
+    <tr>
       <td>Ville</td>
       <td><input type="text" name="city" size="32" value="{$smarty.request.city}" /></td>
     </tr>
       <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
     </tr>
   </table>
-  <div class="center">
-    <br />
-    {min_auth level='cookie'}
-    <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} />
-    mettre les fiches modifiées récemment en premier <br /> <br />
-    {/min_auth}
-    <input type="submit" name="rechercher" value="Chercher" />
-  </div>
+       {min_auth level='cookie'}
+       <p>
+               <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} />
+               mettre les fiches modifiées récemment en premier
+       </p>
+       {/min_auth}
+       <input type="hidden" name="rechercher" value="Chercher"/>
+       <input type="submit" style="display:none" value="Chercher" onClick="launch_form('{$smarty.server.PHP_SELF}')"/>
 </form>
+       <p class="center">
+               <script type="text/javascript">{literal}
+               function launch_form(url) {
+                       var f = document.getElementById('recherche');
+                       f.action = url;
+                       f.submit();
+               }
+               {/literal}</script>
+               <input type="button" value="Voir les résultats sur une carte" onClick="launch_form('geoloc/')"/>
+               <input type="button" value="Chercher" onClick="launch_form('{$smarty.server.PHP_SELF}')"/>
+  </p>
 <p>
   <strong>N.B.</strong> Le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.
 </p>
index 57cc99f..3df8b19 100644 (file)
 
 
 {if $formulaire==0 and !$xorg_errors|count}
-  {if !$advanced}
-  {include file='search.quick.form.tpl' show_js=1}
-  {else}
-  {include file=search.adv.links.tpl do_title=1 with_soundex=$with_soundex}
+  {if !$simple}
+    {if !$advanced}
+    {include file='search.quick.form.tpl' show_js=1}
+    {else}
+    {include file=search.adv.links.tpl do_title=1 with_soundex=$with_soundex}
+    {/if}
   {/if}
 
   <h1 class='right'>
     {if $search_results_nb==0}Aucune{else}{$search_results_nb}{/if} réponse{if $search_results_nb>1}s{/if}.
   </h1>
 
+  {if $search_results_nb and $advanced and !$simple}
+  <p>
+       [<a href='geoloc/?{$search_vars}'>Voir la recherche sur une carte</a>].
+  </p>
+  {/if}
+  
   {if $search_results_nb > 1}
   <div>
     Trier par :
diff --git a/upgrade/0.9.10/00_geoloc.sql b/upgrade/0.9.10/00_geoloc.sql
new file mode 100644 (file)
index 0000000..4db8efb
--- /dev/null
@@ -0,0 +1,24 @@
+CREATE TABLE `geoloc_city_in_maps` (\r
+  `city_id` int(11) NOT NULL default '0',\r
+  `map_id` int(11) NOT NULL default '0',\r
+  `infos` set('smallest') NOT NULL default '',\r
+   PRIMARY KEY  (`map_id`,`infos`,`city_id`)\r
+);\r
+insert into admin_a VALUES (11, "Dynamap", "admin/geoloc_dynamap.php", 10);\r
+UPDATE `adresses` AS a, `geoloc_city` AS c SET a.glng = c.lon /100000, a.glat = c.lat /100000 WHERE a.cityid = c.id;\r
+CREATE TABLE `geoloc_maps` (\r
+       `map_id` int(11) NOT NULL default '0',\r
+  `name` varchar(50) NOT NULL default '',\r
+  `x` double NOT NULL default '0',\r
+  `y` double NOT NULL default '0',\r
+  `width` double NOT NULL default '0',\r
+  `height` double NOT NULL default '0',\r
+  `xclip` float NOT NULL default '0',\r
+  `yclip` float NOT NULL default '0',\r
+  `scale` int(11) NOT NULL default '1',\r
+  `parent` int(11) default NULL,\r
+  `path` varchar(65) NOT NULL default '',\r
+  PRIMARY KEY  (`map_id`),\r
+  KEY `parent` (`parent`),\r
+  KEY `path` (`path`)\r
+       );\r
diff --git a/upgrade/0.9.10/update.sh b/upgrade/0.9.10/update.sh
new file mode 100755 (executable)
index 0000000..de82fc0
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+mailman_stop
+mailman_templates
+mailman_start
+
+
+###########################################################
+for sql in *.sql
+do
+    echo -n $sql
+    $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR"
+    echo .
+done
+
+###########################################################
+
+echo "we will now upgrade the search table (this may be a long operation)
+
+please hit ^D to continue
+"
+
+cat
+
+pushd ../../bin
+./search.rebuild_db.php
+popd
+
+###########################################################
+