--- /dev/null
+<?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:
+?>
--- /dev/null
+<?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:
+?>
+
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");
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";
return Array($liste, $nb_tot);
}
- // }}}
+// }}}
$search = new XOrgSearch('get_list');
$search->setNbLines($globals->search->per_page);
<?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:
?>
--- /dev/null
+<?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();
+?>
--- /dev/null
+<?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:
+?>
--- /dev/null
+<?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).'&';
+$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:
+?>
--- /dev/null
+<?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");
+
+?>
$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().'&';
+if (Env::has('only_current') && Env::get('only_current') != 'on') $search .= '&only_current=';
+$search = preg_replace('/(^|&)mapid=([0-9]+)(&|$)/','\1\3', $search);
+if ($search)
+ $page->assign('dynamap_vars', $search);
+
$page->run();
// vim:set et sws=4 sw=4 sts=4:
* @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) => "œ")));
- global $globals;
if ($infos['sql'])
$globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']);
if ($infos['display'])
}
// }}}
+// {{{ 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
$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;
* @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:
?>
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
}
// }}}
+
+// {{{ 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
// }}}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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: *}
--- /dev/null
+{**************************************************************************}\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
--- /dev/null
+{**************************************************************************}\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
--- /dev/null
+{**************************************************************************}\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
{**************************************************************************}
{* *}
-{* 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"}&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: *}
<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>
{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 :
--- /dev/null
+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
--- /dev/null
+#!/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
+
+###########################################################
+