OR (profile_freetext_pub != 'private' AND profile_freetext_pub != 'public')
OR (profile_medals_pub != 'private' AND profile_medals_pub != 'public')",
"Utilisateur n'ayant pas de flag de publicite pour leurs donnees de profil");
-check("select uid from adresses where pub != 'private' and pub !='ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour une adresse");
+check("SELECT pid
+ FROM profile_addresses
+ WHERE pub != 'private' AND pub !='ax' AND pub != 'public'",
+ "Utiliseur n'ayant pas de flag de publicité pour une adresse.");
check("select uid from profile_phones where pub != 'private' and pub != 'ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de téléphone");
check("select uid from profile_networking where pub != 'private' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicité pour une adresse de networking");
check("select p.* from photo as p left join auth_user_md5 as u on u.user_id=p.uid where u.prenom is null");
/* validite des formats téléphoniques */
-check("SELECT DISTINCT g.phoneprf from geoloc_pays AS g
- WHERE EXISTS (SELECT h.phoneprf
- FROM geoloc_pays AS h
- WHERE h.phoneprf = g.phoneprf AND h.phoneformat != (SELECT i.phoneformat
- FROM geoloc_pays AS i
- WHERE i.phoneprf = g.phoneprf
- LIMIT 1))",
+check("SELECT DISTINCT g.phonePrefix
+ FROM geoloc_countries AS g
+ WHERE EXISTS (SELECT h.phonePrefix
+ FROM geoloc_countries AS h
+ WHERE h.phonePrefix = g.phonePrefix
+ AND h.phoneFormat != (SELECT i.phoneFormat
+ FROM geoloc_countries AS i
+ WHERE i.phonePrefix = g.phonePrefix
+ LIMIT 1))",
"Préfixes téléphoniques qui ont des formats de numéros de téléphones différents selon les pays");
-/* validite des champ pays et region */
-check("SELECT a.uid, a.country FROM adresses AS a LEFT JOIN geoloc_pays AS gp ON a.country = gp.a2 WHERE gp.pays IS NULL","donne la liste des pays dans les profils qui n'ont pas d'entree correspondante dans geoloc_pays");
-/* les régions ne sont valides que dans les adresses pros */
-//check("SELECT e.uid, e.country, e.region FROM entreprises AS e LEFT JOIN geoloc_region AS gr ON (e.country = gr.a2 AND e.region = gr.region) WHERE e.region != '' AND gr.name IS NULL","donne la liste des regions dans les profils pros qui n'ont pas d'entree correspondante dans geoloc_region");
+/* validite des champ pays */
+check("SELECT a.pid, a.countryId
+ FROM profile_addresses AS a
+ LEFT JOIN geoloc_countries AS gc ON (a.countryId = gc.iso_3166_1_a2)
+ WHERE gc.countryFR IS NULL OR gc.countryFR = ''",
+ "donne la liste des pays dans les profils qui n'ont pas d'entree correspondante dans geoloc_countries");
/* donne la liste des emails douteux que les administrateurs n'ont pas encore traité */
check("SELECT a1.alias, a2.alias, e1.email, e2.flags
ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)");
}
-$res = XDB::query("SELECT DISTINCT g.phoneprf FROM geoloc_pays AS g WHERE g.phoneprf IS NOT NULL");
+$res = XDB::query("SELECT DISTINCT phonePrefix
+ FROM geoloc_countries
+ WHERE phonePrefix IS NOT NULL");
$prefixes = $res->fetchColumn();
foreach ($prefixes as $i => $prefix) {
- $res = XDB::query("SELECT g.phoneformat FROM geoloc_pays AS g
- WHERE g.phoneprf = {?} AND g.phoneformat != '' LIMIT 1",
+ $res = XDB::query("SELECT phoneFormat
+ FROM geoloc_countries
+ WHERE phonePrefix = {?} AND phoneFormat != '' LIMIT 1",
$prefix);
if ($res->numRows() > 0) {
$format = $res->fetchOneCell();
if ($perms->hasFlag('groupannu')) {
$sub['annuaire du groupe'] = "$dim/annuaire";
$sub['trombinoscope'] = "$dim/trombi";
- $sub['planisphère'] = "$dim/geoloc";
}
if ($perms->hasFlag('groupmember')) {
if ($globals->asso('forum')) {
event_forum = ""
event_reply = ""
-[Geoloc]
-webservice_url = ""
+[Geocoder]
+email = ""
+gmaps_key = ""
+gmaps_url = "http://maps.google.com/maps/geo"
[Lists]
rpchost = "localhost"
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-// Page initialization
+// Page initialization {{{1
function wizPage_onLoad(id)
{
prepareType(j);
}
break;
+ case 'adresses':
+ checkCurrentAddress();
+ break;
case 'poly':
updateGroupSubLink(document.forms.prof_annu.groupesx_sub);
break;
var educationDegree;
var educationDegreeAll;
var educationDegreeName;
-
-// General
-
var subgrades;
var names;
+
+// Education {{{1
+
function fillType(selectCtrl, edu, fill)
{
var i;
selectType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edu_" + i + "_tmp"].value);
}
+function addEdu()
+{
+ var i = 0;
+ var j = 0;
+ var prefix = 'edu_';
+ var class_parity;
+
+ while (!$('#edu_add').hasClass(prefix + i)) {
+ if ($('.' + prefix + i).length != 0) {
+ j++;
+ }
+ i++;
+ }
+ if (j % 2) {
+ class_parity = 'pair';
+ } else {
+ class_parity = 'impair';
+ }
+ $('#edu_add').removeClass(prefix + i);
+ i++;
+ $('#edu_add').addClass(prefix + i);
+ i--;
+ $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
+ function(data) {
+ $('#edu_add').before(data);
+ prepareType(i);
+ });
+}
+
+function removeEdu(i)
+{
+ var prefix = 'edu_';
+ $('.' + prefix + i).remove();
+ while (!$('#edu_add').hasClass(prefix + i)) {
+ $('.' + prefix + i).toggleClass('pair');
+ $('.' + prefix + i).toggleClass('impair');
+ i++;
+ }
+}
+
+// Names {{{1
+
function toggleNamesAdvanced()
{
$('.names_advanced').toggle();
});
}
+// Nationalities {{{1
+
function delNationality(i)
{
$('#nationalite' + i).hide().find('select').val('');
}
}
+// Networking {{{1
+
function addNetworking()
{
var i = 0;
}
-// Addresses
-
-function removeObject(id, pref)
-{
- document.getElementById(id).style.display = "none";
- document.forms.prof_annu[pref + "[removed]"].value = "1";
-}
-
-function restoreObject(id, pref)
-{
- document.getElementById(id).style.display = '';
- document.forms.prof_annu[pref + "[removed]"].value = "0";
-}
+// Addresses {{{1
-function getAddressElement(adrid, adelement)
+function toggleAddress(id, val)
{
- return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"];
+ $('#addresses_' + id + '_grayed').toggle();
+ $('#addresses_' + id).toggle();
+ $('#addresses_' + id + '_cont').find('[name*=removed]').val(val);
+ checkCurrentAddress();
}
-function checkCurrentAddress(newCurrent)
+function checkCurrentAddress(id)
{
- var hasCurrent = false;
+ var hasCurrentAddress = id ? true : false;
var i = 0;
- while (getAddressElement(i, 'pub') != null) {
- var radio = getAddressElement(i, 'current');
- var removed = getAddressElement(i, 'removed');
- if (removed.value == "1" && radio.checked) {
- radio.checked = false;
- } else if (radio.checked && radio != newCurrent) {
- radio.checked = false;
- } else if (radio.checked) {
- hasCurrent = true;
+ while ($('#addresses_' + i + '_cont').length != 0) {
+ if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 1) {
+ $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
+ }
+ if (!hasCurrentAddress && $('#addresses_' + i + '_cont').find('[name*=current]:checked').length != 0) {
+ hasCurrentAddress = true;
+ } else {
+ $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
}
i++;
}
- if (!hasCurrent) {
+ if (!hasCurrentAddress) {
i = 0;
- while (getAddressElement(i, 'pub') != null) {
- var radio = getAddressElement(i, 'current');
- var removed = getAddressElement(i, 'removed');
- if (removed.value != "1") {
- radio.checked= true;
- return;
- }
- i++;
+ while ($('#addresses_' + i + '_cont').length != 0) {
+ if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 0) {
+ $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', 'checked');
+ break;
+ }
+ i++;
}
}
-}
-
-function removeAddress(id, pref)
-{
- removeObject(id, pref);
- checkCurrentAddress(null);
- if (document.forms.prof_annu[pref + '[datemaj]'].value != '') {
- document.getElementById(id + '_grayed').style.display = '';
+ if (id) {
+ $('#addresses_' + id + '_cont').find('[name*=current]').attr('checked', 'checked');
}
}
-function restoreAddress(id, pref)
-{
- document.getElementById(id + '_grayed').style.display = 'none';
- checkCurrentAddress(null);
- restoreObject(id, pref);
-}
-
function addAddress()
{
var i = 0;
- while (getAddressElement(i, 'pub') != null) {
+ while ($('#addresses_' + i + '_cont').length != 0) {
i++;
}
- $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>');
- Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
+ $('#add_address').before('<div id="addresses_' + i + '_cont"></div>');
+ Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress());
}
-function addEdu()
+function addressChanged(id)
{
- var i = 0;
- var j = 0;
- var prefix = 'edu_';
- var class_parity;
-
- while (!$('#edu_add').hasClass(prefix + i)) {
- if ($('.' + prefix + i).length != 0) {
- j++;
- }
- i++;
- }
- if (j % 2) {
- class_parity = 'pair';
- } else {
- class_parity = 'impair';
- }
- $('#edu_add').removeClass(prefix + i);
- i++;
- $('#edu_add').addClass(prefix + i);
- i--;
- $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
- function(data) {
- $('#edu_add').before(data);
- prepareType(i);
- });
+ $('#addresses_' + id + '_cont').find('[name*=changed]').val("1");
}
-function removeEdu(i)
+function validGeoloc(id, geoloc)
{
- var prefix = 'edu_';
- $('.' + prefix + i).remove();
- while (!$('#edu_add').hasClass(prefix + i)) {
- $('.' + prefix + i).toggleClass('pair');
- $('.' + prefix + i).toggleClass('impair');
- i++;
+ if (geoloc == 1) {
+ $('#addresses_' + id + '_cont').find('[name*=text]').val($('#addresses_' + id + '_cont').find('[name*=geoloc]').val());
+ $('#addresses_' + id + '_cont').find('[name*=postalText]').val($('#addresses_' + id + '_cont').find('[name*=geocodedPostalText]').val());
}
+ $('#addresses_' + id + '_cont').find('[name*=text]').removeClass('error');
+ $('#addresses_' + id + '_cont').find('[name*=geoloc_choice]').val(geoloc);
+ $('.addresses_' + id + '_geoloc').remove();
}
+// {{{1 Phones
+
function addTel(prefid, prefname)
{
var i = 0;
document.getElementById(id+'_addComment').style.display = '';
}
-// Geoloc
-
-function validGeoloc(id, pref)
-{
- document.getElementById(id + '_geoloc').style.display = 'none';
- document.getElementById(id + '_geoloc_error').style.display = 'none';
- document.getElementById(id + '_geoloc_valid').style.display = 'none';
- document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
- document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
- document.forms.prof_annu[pref + "[cityid]"].value = document.forms.prof_annu[pref + "[geoloc_cityid]"].value;
- $(document.forms.prof_annu[pref + "[text]"]).click(function() { document.forms.prof_annu[pref + "[text]"].blur(); });
- document.forms.prof_annu[pref + "[text]"].className = '';
-}
-
-function validAddress(id, pref)
-{
- document.getElementById(id + '_geoloc').style.display = 'none';
- document.getElementById(id + '_geoloc_error').style.display = 'none';
- document.getElementById(id + '_geoloc_valid').style.display = 'none';
- document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
- $(document.forms.prof_annu[pref + "[text]"]).click(function() { document.forms.prof_annu[pref + "[text]"].blur(); });
- document.forms.prof_annu[pref + "[text]"].className = '';
-}
-
-
-// Groups
+// Groups {{{1
function updateGroup(type)
{
document.getElementById("groupesx_sub").href = href;
}
-
-// Medals
+// Medals {{{1
function updateMedal()
{
updateMedal();
}
-
-// Jobs
+// Jobs {{{1
function removeJob(id, pref)
{
$('.entreprise_' + id).toggle();
}
-// Skills
+// {{{1 Skills
function updateSkill(cat)
{
updateSkill(cat);
}
-
-// Mentor
+// Mentor {{{1
function updateCountry()
{
require_once dirname(__FILE__).'/../include/xorg.inc.php';
$platal = new Xorg('auth', 'carnet', 'email', 'events', 'forums',
- 'geoloc', 'lists', 'marketing', 'payment', 'platal',
+ 'lists', 'marketing', 'payment', 'platal',
'profile', 'register', 'search', 'stats', 'admin',
'newsletter', 'axletter', 'bandeau', 'survey',
'fusionax', 'gadgets', 'googleapps', 'poison', 'openid');
function education_options($current = 0)
{
$html = '<option value="-1"></option>';
- $res = XDB::iterator("SELECT e.id AS id, g.pays AS country,
+ $res = XDB::iterator("SELECT e.id AS id, gc.countryFR AS country,
IF(CHAR_LENGTH(e.name) > 76, e.abbreviation, e.name) AS name
FROM profile_education_enum AS e
- LEFT JOIN geoloc_pays AS g ON (e.country = g.a2)
+ LEFT JOIN geoloc_countries AS gc ON (e.country = gc.iso_3166_1_a2)
WHERE EXISTS (SELECT *
FROM profile_education_degree AS d
WHERE e.id = d.eduid)
- ORDER BY g.pays, e.name");
+ ORDER BY gc.countryFR, e.name");
$country = "";
while ($arr_edu = $res->next()) {
if ($arr_edu["country"] != $country) {
$html = "";
$res = XDB::iterRow("SELECT d.eduid, d.degreeid
FROM profile_education_enum AS e
- INNER JOIN profile_education_degree AS d ON (e.id = d.eduid)
- LEFT JOIN geoloc_pays AS g ON (e.country = g.a2)
- ORDER BY g.pays, e.name");
+ INNER JOIN profile_education_degree AS d ON (e.id = d.eduid)
+ LEFT JOIN geoloc_countries AS gc ON (e.country = gc.a2)
+ ORDER BY gc.countryFR, e.name");
if ($edu_degree = $res->next()) {
$eduid = $edu_degree['0'];
$html .= "[";
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2009 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 *
+ ***************************************************************************/
+
+// Interface for an address geocoder. It provides support for transforming a free
+// form address into a fully structured one.
+// TODO: define and use an Address object instead of a key-value map.
+abstract class Geocoder {
+ // Geocodes @p the address, and returns the corresponding updated address.
+ // Unknown key-value pairs available in the input map are retained as-is.
+ abstract public function getGeocodedAddress(array $address);
+
+ // Cleans the address from its geocoded data
+ abstract public function stripGeocodingFromAddress(array $address);
+
+ // Updates geoloc_administrativeareas, geoloc_subadministrativeareas and
+ // geoloc_localities databases with new geocoded data and returns the
+ // corresponding id.
+ static public function getAreaId(array &$address, $area)
+ {
+ static $databases = array(
+ 'administrativeArea' => 'geoloc_administrativeareas',
+ 'subAdministrativeArea' => 'geoloc_subadministrativeareas',
+ 'locality' => 'geoloc_localities',
+ );
+
+ if (isset($address[$area . 'Name']) && isset($databases[$area])) {
+ $res = XDB::query("SELECT id
+ FROM " . $databases[$area] . "
+ WHERE name = {?}",
+ $address[$area . 'Name']);
+ if ($res->numRows() == 0) {
+ $address[$area . 'Id'] = XDB::execute("INSERT INTO " . $databases[$area] . " (name, country)
+ VALUES ({?}, {?})",
+ $address[$area . 'Name'], $address['countryId']);
+ } else {
+ $address[$area . 'Id'] = $res->fetchOneCell();
+ }
+ }
+ }
+
+ // Returns the part of the text preceeding the line with the postal code
+ // and the city name, within the limit of $limit number of lines.
+ static public function getFirstLines($text, $postalCode, $limit)
+ {
+ $textArray = explode("\n", $text);
+ for ($i = 0; $i < count($textArray); ++$i) {
+ if ($i > $limit || strpos($textLine, $postalCode) !== false) {
+ $limit = $i; break;
+ }
+ }
+ return implode("\n", array_slice($textArray, 0, $limit));
+ }
+
+ // Returns the number of non geocoded addresses for a user.
+ static public function countNonGeocoded($pid)
+ {
+ $res = XDB::query("SELECT COUNT(*)
+ FROM profile_addresses
+ WHERE pid = {?} AND FIND_IN_SET('home', type) AND accuracy = 0",
+ $pid);
+ return $res->fetchOneCell();
+ }
+}
+
+// Implementation of a Geocoder using the Google Maps API. Please refer to
+// the following links for details:
+// http://code.google.com/apis/maps/documentation/services.html#Geocoding
+// http://code.google.com/intl/en/apis/maps/documentation/geocoding/
+// http://code.google.com/apis/maps/documentation/reference.html#GGeoAddressAccuracy
+//
+// It requires the properties gmaps_key and gmaps_url to be defined in section
+// Geocoder in plat/al's configuration (platal.ini & platal.conf).
+class GMapsGeocoder extends Geocoder {
+
+ // Maximum number of Geocoding calls to the Google Maps API.
+ const MAX_GMAPS_RPC_CALLS = 5;
+
+ public function getGeocodedAddress(array $address) {
+ $address = $this->prepareAddress($address);
+ $textAddress = $address['text'];
+
+ // Try to geocode the full address.
+ if (($geocodedData = $this->getPlacemarkForAddress($textAddress))) {
+ return $this->getUpdatedAddress($address, $geocodedData, null);
+ }
+
+ // If the full geocoding failed, try to geocode only the final part of the address.
+ // We start by geocoding everything but the first line, and continue until we get
+ // a result. To respect the limit of GMaps calls, we ignore the first few lines
+ // if there are too many address lines.
+ $addressLines = explode("\n", $textAddress);
+ $linesCount = count($addressLines);
+ for ($i = max(1, $linesCount - self::MAX_GMAPS_RPC_CALLS + 1); $i < $linesCount; ++$i) {
+ $extraLines = implode("\n", array_slice($addressLines, 0, $i));
+ $toGeocode = implode("\n", array_slice($addressLines, $i));
+ if (($geocodedData = $this->getPlacemarkForAddress($toGeocode))) {
+ return $this->getUpdatedAddress($address, $geocodedData, $extraLines);
+ }
+ }
+
+ // No geocoding could be done, the initial address is returned as-is.
+ return $address;
+ }
+
+ public function stripGeocodingFromAddress(array $address) {
+ unset($address['geoloc'], $address['geoloc_choice'], $address['geocodedPostalText'],
+ $address['countryId'], $address['country'], $address['administrativeAreaName'],
+ $address['subAdministrativeAreaName'], $address['localityName'],
+ $address['thoroughfareName'], $address['postalCode']);
+ $address['accuracy'] = 0;
+ return $address;
+ }
+
+ // Updates the address with the geocoded information from Google Maps. Also
+ // cleans up the final informations.
+ private function getUpdatedAddress(array $address, array $geocodedData, $extraLines) {
+ $this->fillAddressWithGeocoding(&$address, $geocodedData);
+
+ // If the accuracy is 6, it means only the street has been gecoded
+ // but not the number, thus we need to fix it.
+ if ($address['accuracy'] == 6) {
+ $this->fixStreetNumber($address);
+ }
+
+ // We can now format the address.
+ $this->formatAddress($address, $extraLines);
+
+ // Some entities in ISO 3166 are not countries, thus they have to be replaced
+ // by the country they belong to.
+ // TODO: fixCountry($address);
+
+ return $address;
+ }
+
+ // Retrieves the Placemark object (see #getPlacemarkFromJson()) for the @p
+ // address, by querying the Google Maps API. Returns the array on success,
+ // and null otherwise.
+ private function getPlacemarkForAddress($address) {
+ $url = $this->getGeocodingUrl($address);
+ $geoData = $this->getGeoJsonFromUrl($url);
+
+ return ($geoData ? $this->getPlacemarkFromJson($geoData) : null);
+ }
+
+ // Prepares address to be geocoded
+ private function prepareAddress($address) {
+ $address['text'] = preg_replace('/\s*\n\s*/m', "\n", trim($address['text']));
+ $address['postalText'] = $this->getPostalAddress($address['text']);
+ $address['updateTime'] = time();
+ unset($address['changed']);
+ return $address;
+ }
+
+ // Builds the Google Maps geocoder url to fetch information about @p address.
+ // Returns the built url.
+ private function getGeocodingUrl($address) {
+ global $globals;
+
+ $parameters = array(
+ 'key' => $globals->geocoder->gmaps_key,
+ 'sensor' => 'false', // The queried address wasn't obtained from a GPS sensor.
+ 'hl' => 'fr', // Output langage.
+ 'oe' => 'utf8', // Output encoding.
+ 'output' => 'json', // Output format.
+ 'gl' => 'fr', // Location preferences (addresses are in France by default).
+ 'q' => $address, // The queries address.
+ );
+
+ return $globals->geocoder->gmaps_url . '?' . http_build_query($parameters);
+ }
+
+ // Fetches JSON-encoded data from a Google Maps API url, and decode them.
+ // Returns the json array on success, and null otherwise.
+ private function getGeoJsonFromUrl($url) {
+ global $globals;
+
+ // Prepare a backtrace object to log errors.
+ $bt = null;
+ if ($globals->debug & DEBUG_BT) {
+ if (!isset(PlBacktrace::$bt['Geoloc'])) {
+ new PlBacktrace('Geoloc');
+ }
+ $bt = &PlBacktrace::$bt['Geoloc'];
+ $bt->start($url);
+ }
+
+ // Fetch the geocoding data.
+ $rawData = file_get_contents($url);
+ if (!$rawData) {
+ if ($bt) {
+ $bt->stop(0, "Could not retrieve geocoded address from GoogleMaps.");
+ }
+ return null;
+ }
+
+ // Decode the JSON-encoded data, and check for their validity.
+ $data = json_decode($rawData, true);
+ if ($bt) {
+ $bt->stop(count($data), null, $data);
+ }
+
+ return $data;
+ }
+
+ // Extracts the most appropriate placemark from the JSON data fetched from
+ // Google Maps. Returns a Placemark array on success, and null otherwise. See
+ // http://code.google.com/apis/maps/documentation/services.html#Geocoding_Structured
+ // for details on the Placemark structure.
+ private function getPlacemarkFromJson(array $data) {
+ // Check for geocoding failures.
+ if (!isset($data['Status']['code']) || $data['Status']['code'] != 200) {
+ // TODO: handle non-200 codes in a better way, since the code might
+ // indicate a temporary error on Google's side.
+ return null;
+ }
+
+ // Check that at least one placemark was found.
+ if (count($data['Placemark']) == 0) {
+ return null;
+ }
+
+ // Extract the placemark with the best accuracy. This is not always the
+ // best result (since the same address may yield two different placemarks).
+ $result = $data['Placemark'][0];
+ foreach ($data['Placemark'] as $place) {
+ if ($place['AddressDetails']['Accuracy'] > $result['AddressDetails']['Accuracy']) {
+ $result = $place;
+ }
+ }
+
+ return $result;
+ }
+
+ // Fills the address with the geocoded data
+ private function fillAddressWithGeocoding(&$address, $geocodedData) {
+ // The geocoded address three is
+ // Country -> AdministrativeArea -> SubAdministrativeArea -> Locality -> Thoroughfare
+ // with all the possible shortcuts
+ // The address is formatted as xAL, or eXtensible Address Language, an international
+ // standard for address formatting.
+ // xAL documentation: http://www.oasis-open.org/committees/ciq/ciq.html#6
+ $address['geoloc'] = str_replace(", ", "\n", $geocodedData['address']);
+ if (isset($geocodedData['AddressDetails']['Accuracy'])) {
+ $address['accuracy'] = $geocodedData['AddressDetails']['Accuracy'];
+ }
+
+ $currentPosition = $geocodedData['AddressDetails'];
+ if (isset($currentPosition['Country'])) {
+ $currentPosition = $currentPosition['Country'];
+ $address['countryId'] = $currentPosition['CountryNameCode'];
+ $address['country'] = $currentPosition['CountryName'];
+ }
+ if (isset($currentPosition['AdministrativeArea'])) {
+ $currentPosition = $currentPosition['AdministrativeArea'];
+ $address['administrativeAreaName'] = $currentPosition['AdministrativeAreaName'];
+ }
+ if (isset($currentPosition['SubAdministrativeArea'])) {
+ $currentPosition = $currentPosition['SubAdministrativeArea'];
+ $address['subAdministrativeAreaName'] = $currentPosition['SubAdministrativeAreaName'];
+ }
+ if (isset($currentPosition['Locality'])) {
+ $currentPosition = $currentPosition['Locality'];
+ $address['localityName'] = $currentPosition['LocalityName'];
+ }
+ if (isset($currentPosition['Thoroughfare'])) {
+ $address['thoroughfareName'] = $currentPosition['Thoroughfare']['ThoroughfareName'];
+ }
+ if (isset($currentPosition['PostalCode'])) {
+ $address['postalCode'] = $currentPosition['PostalCode']['PostalCodeNumber'];
+ }
+
+ // Gets coordinates.
+ if (isset($geocodedData['Point']['coordinates'][0])) {
+ $address['latitude'] = $geocodedData['Point']['coordinates'][0];
+ }
+ if (isset($geocodedData['Point']['coordinates'][1])) {
+ $address['longitude'] = $geocodedData['Point']['coordinates'][1];
+ }
+ if (isset($geocodedData['ExtendedData']['LatLonBox']['north'])) {
+ $address['north'] = $geocodedData['ExtendedData']['LatLonBox']['north'];
+ }
+ if (isset($geocodedData['ExtendedData']['LatLonBox']['south'])) {
+ $address['south'] = $geocodedData['ExtendedData']['LatLonBox']['south'];
+ }
+ if (isset($geocodedData['ExtendedData']['LatLonBox']['east'])) {
+ $address['east'] = $geocodedData['ExtendedData']['LatLonBox']['east'];
+ }
+ if (isset($geocodedData['ExtendedData']['LatLonBox']['west'])) {
+ $address['west'] = $geocodedData['ExtendedData']['LatLonBox']['west'];
+ }
+ }
+
+ // Formats the text of the geocoded address using the unused data and
+ // compares it to the given address. If they are too different, the user
+ // will be asked to choose between them.
+ private function formatAddress(&$address, $extraLines) {
+ $same = true;
+ if ($extraLines) {
+ $address['geoloc'] = $extraLines . "\n" . $address['geoloc'];
+ }
+ $address['geocodedPostalText'] = $this->getPostalAddress($address['geoloc']);
+ $geoloc = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"),
+ array("", "\n"), $address['geoloc']));
+ $text = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"),
+ array("", "\n"), $address['text']));
+ $arrayGeoloc = explode("\n", $geoloc);
+ $arrayText = explode("\n", $text);
+ $countGeoloc = count($arrayGeoloc);
+ $countText = count($arrayText);
+
+ if (($countText > $countGeoloc) || ($countText < $countGeoloc - 1)
+ || (($countText == $countGeoloc - 1)
+ && ($arrayText[$countText - 1] == strtoupper($address['country'])))) {
+ $same = false;
+ } else {
+ for ($i = 0; $i < $countGeoloc && $i < $countText; ++$i) {
+ if (levenshtein($arrayText[$i], trim($arrayGeoloc[$i])) > 3) {
+ $same = false;
+ }
+ }
+ }
+ if ($same) {
+ $address['text'] = $address['geoloc'];
+ $address['postalText'] = $address['geocodedPostalText'];
+ unset($address['geoloc'], $address['geocodedPostalText']);
+ }
+ }
+
+ // Returns the address formated for postal use.
+ // The main rules are (cf AFNOR XPZ 10-011):
+ // -everything in upper case;
+ // -if there are more then than 38 characters in a lign, split it;
+ // -if there are more then than 32 characters in the description of the "street", use abbreviations.
+ private function getPostalAddress($text) {
+ static $abbreviations = array(
+ "IMPASSE" => "IMP",
+ "RUE" => "R",
+ "AVENUE" => "AV",
+ "BOULEVARD" => "BVD",
+ "ROUTE" => "R",
+ "STREET" => "ST",
+ "ROAD" => "RD",
+ );
+
+ $text = strtoupper($text);
+ $arrayText = explode("\n", $text);
+ $postalText = "";
+
+ foreach ($arrayText as $i => $lign) {
+ $postalText .= (($i == 0) ? "" : "\n");
+ if (($length = strlen($lign)) > 32) {
+ $words = explode(" ", $lign);
+ $count = 0;
+ foreach ($words as $word) {
+ if (isset($abbreviations[$word])) {
+ $word = $abbreviations[$word];
+ }
+ if ($count + ($wordLength = strlen($word)) <= 38) {
+ $postalText .= (($count == 0) ? "" : " ") . $word;
+ $count += (($count == 0) ? 0 : 1) + $wordLength;
+ } else {
+ $postalText .= "\n" . $word;
+ $count = strlen($word);
+ }
+ }
+ } else {
+ $postalText .= $lign;
+ }
+ }
+ return $postalText;
+ }
+
+ // Search for the lign from the given address that is the closest to the geocoded thoroughfareName
+ // and replaces the corresponding lign in the geocoded text by it.
+ static protected function fixStreetNumber(&$address)
+ {
+ if (isset($address['thoroughfareName'])) {
+ $thoroughfareName = $address['thoroughfareName'];
+ $thoroughfareToken = strtoupper(trim(preg_replace(array("/[,\"'#~:;_\-]/", "/\r\n/"),
+ array("", "\n"), $thoroughfareName)));
+ $geolocLines = explode("\n", $address['geoloc']);
+ $textLines = explode("\n", $address['text']);
+ $mindist = strlen($thoroughfareToken);
+ $minpos = 0;
+ $pos = 0;
+ foreach ($textLines as $i => $token) {
+ if (($l = levenshtein(strtoupper(trim(preg_replace(array("/[,\"'#~:;_\-]/", "/\r\n/"),
+ array("", "\n"), $token))),
+ $thoroughfareToken)) < $mindist) {
+ $mindist = $l;
+ $minpos = $i;
+ }
+ }
+ foreach ($geolocLines as $i => $line) {
+ if (strtoupper(trim($thoroughfareName)) == strtoupper(trim($line))) {
+ $pos = $i;
+ break;
+ }
+ }
+ $geolocLines[$pos] = $textLines[$minpos];
+ $address['geoloc'] = implode("\n", $geolocLines);
+ }
+ }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2009 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 *
- ***************************************************************************/
-
-// {{{ liste les pays ou les régions d'un pays
-/** donne la liste déroulante des pays
- * @param $current pays actuellement selectionné
- */
-function geoloc_country($current, $avail_only = false)
-{
- if ($avail_only) {
- $res = XDB::iterRow('SELECT g.a2, g.pays
- FROM geoloc_pays AS g
- INNER JOIN adresses AS a ON(a.country = g.a2)
- GROUP BY g.a2
- ORDER BY g.pays');
- } else {
- $res = XDB::iterRow('SELECT a2,pays FROM geoloc_pays ORDER BY pays');
- }
- $html = "";
- while (list($my_id, $my_pays) = $res->next()) {
- $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
- $my_id, ($current==$my_id?"selected='selected'":""), $my_pays);
- }
- return $html;
-}
-
-/** donne la liste deroulante des regions pour un pays
- * @param $pays le pays dont on veut afficher les regions
- * @param $current la region actuellement selectionnee
- */
-function geoloc_region($country, $current, $avail_only = false)
-{
- if ($avail_only) {
- $res = XDB::iterRow('SELECT r.region, r.name
- FROM geoloc_region AS r
- INNER JOIN adresses AS a ON (a.country = r.a2 AND a.region = r.region)
- WHERE r.a2 = {?}
- GROUP BY r.region
- ORDER BY r.name', $country);
- } else {
- $res = XDB::iterRow('SELECT region,name
- FROM geoloc_region
- WHERE a2 = {?}
- ORDER BY name', $country);
- }
- $html = "<option value=\"\"></option>";
- while (list($regid, $regname) = $res->next()) {
- $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
- $regid, ($current==$regid?"selected='selected'":""), $regname);
- }
- return $html;
-}
-// }}}
-
-// {{{ get_address_infos($txt)
-/** retrieve the infos on a text address
- * store on the fly the info of the city concerned
- * @param $txt the raw text of an address
- */
-function get_address_infos($txt)
-{
- global $globals;
-
- $url = $globals->geoloc->webservice_url."address.php?precise=1&txt=" . urlencode($txt);
- if ($globals->debug & DEBUG_BT) {
- if (!isset(PlBacktrace::$bt['Geoloc'])) {
- new PlBacktrace('Geoloc');
- }
- PlBacktrace::$bt['Geoloc']->start($url);
- }
- $f = @fopen($url, 'r');
- if ($f === false) {
- if ($globals->debug & DEBUG_BT) {
- PlBacktrace::$bt['Geoloc']->stop(0, 'Can\'t fetch result');
- }
- return false;
- }
- $keys = explode('|',fgets($f));
- $vals = explode('|',fgets($f));
- if ($globals->debug & DEBUG_BT) {
- $data = array();
- for ($i = 0 ; $i < count($keys) ; ++$i) {
- $data[] = array($keys[$i], $vals[$i]);
- }
- PlBacktrace::$bt['Geoloc']->stop(count($keys), null, $data);
- }
- $infos = empty_address();
- foreach ($keys as $i=>$key) {
- if($vals[$i]) {
- if ($key == 'sql') {
- $infos[$key] = $vals[$i];
- } else {
- $val = strtr($vals[$i], array(chr(197).chr(147) => "œ"));
- $infos[$key] = $val;
- }
- }
- }
- if (empty($infos['country'])) {
- $infos['country'] = '00';
- }
- if (isset($infos['sql']) && $infos['sql']) {
- $sql = explode(', ', trim($infos['sql'], '()'));
- if (count($sql) == 16) {
- for ($i = 0 ; $i < 16 ; ++$i) {
- $sql[$i] = stripslashes(trim($sql[$i], ' \''));
- }
- XDB::execute("REPLACE INTO geoloc_city
- VALUES ({?}, {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?})",
- $sql[0], $sql[1], $sql[2], $sql[3], $sql[4], $sql[5],
- $sql[6], $sql[7], $sql[8], $sql[9], $sql[10], $sql[11],
- $sql[12], $sql[13], $sql[14], $sql[15]);
- }
- }
- if (isset($infos['display']) && $infos['display'])
- XDB::execute("UPDATE geoloc_pays
- SET display = {?}
- WHERE a2 = {?}", $infos['display'], $infos['country']);
- if (isset($infos['cityid'])) {
- fix_cities_not_on_map(1, $infos['cityid']);
- if (floatval($infos['precise_lat']) && floatval($infos['precise_lon'])) {
- $res = XDB::query("SELECT c.lat / 100000, c.lon / 100000
- FROM geoloc_city AS c
- WHERE c.id = {?}", $infos['cityid']);
- if ($res->numRows()) {
- list($glat, $glng) = $res->fetchOneRow();
- $infos['precise_lat'] = $glat;
- $infos['precise_lon'] = $glng;
- }
- }
- }
- return $infos;
-}
-// }}}
-
-// {{{ 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(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;
- }
- 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).')';
- }
- 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
- */
-function get_address_text($adr)
-{
- $t = "";
- if (isset($adr['adr1']) && $adr['adr1']) $t.= $adr['adr1'];
- if (isset($adr['adr2']) && $adr['adr2']) $t.= "\n".$adr['adr2'];
- if (isset($adr['adr3']) && $adr['adr3']) $t.= "\n".$adr['adr3'];
- $l = "";
- if (isset($adr['display']) && $adr['display']) {
- $keys = explode(' ', $adr['display']);
- foreach ($keys as $key) {
- if (isset($adr[$key])) {
- $l .= " ".$adr[$key];
- } else {
- $l .= " ".$key;
- }
- }
- if ($l) substr($l, 1);
- } elseif ($adr['country'] == 'US' || $adr['country'] == 'CA' || $adr['country'] == 'GB') {
- if ($adr['city']) $l .= $adr['city'].",\n";
- if ($adr['region']) $l .= $adr['region']." ";
- if ($adr['postcode']) $l .= $adr['postcode'];
- } else {
- if (isset($adr['postcode']) && $adr['postcode']) $l .= $adr['postcode']." ";
- if (isset($adr['city']) && $adr['city']) $l .= $adr['city'];
- }
- if ($l) $t .= "\n".trim($l);
- if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) {
- $res = XDB::query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']);
- $adr['countrytxt'] = $res->fetchOneCell();
- }
- if (isset($adr['countrytxt']) && $adr['countrytxt']) {
- $t .= "\n".$adr['countrytxt'];
- }
- return trim($t);
-}
-// }}}
-
-// {{{ compare_addresses_text($a, $b)
-/** compares if two address matches
- * @param $a the raw text of an address
- * @param $b the raw text of a complete valid address
- */
-function compare_addresses_text($a, $b)
-{
- $ta = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $a));
- $tb = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $b));
-
- $la = explode("\n", $ta);
- $lb = explode("\n", $tb);
-
- if (count($lb) > count($la) + 1) {
- return false;
- }
- foreach ($la as $i=>$l) {
- if (levenshtein(trim($l), trim($lb[$i])) > 3) {
- return false;
- }
- }
- return true;
-}
-
-// }}}
-
-function empty_address() {
- return Array(
- "adr1" => "",
- "adr2" => "",
- "adr3" => "",
- "cityid" => NULL,
- "city" => "",
- "postcode" => "",
- "region" => "",
- "regiontxt" => "",
- "country" => "00",
- "countrytxt" => "",
- "precise_lat" => "",
- "precise_lon" => "");
-}
-
-// create a simple address from a text without geoloc
-function cut_address($txt)
-{
- $txt = str_replace("\r\n", "\n", $txt);
- ereg("^([^\n]*)(\n([^\n]*)(\n(.*))?)?$", trim($txt), $a);
- return array("adr1" => trim($a[1]), "adr2" => trim($a[3]), "adr3" => trim(str_replace("\n", " ", $a[5])));
-}
-
-// {{{ localize_addresses($uid)
-/* localize all the address of a user and modify the database
- * if the new address match with the old one
- * @param $uid the id of the user
- */
-function localize_addresses($uid)
-{
- $res = XDB::iterator("SELECT *
- FROM adresses
- WHERE uid = {?} and (cityid IS NULL OR cityid = 0)", $uid);
- $erreur = Array();
-
- while ($a = $res->next()) {
- $new = get_address_infos($ta = get_address_text($a));
- if (compare_addresses_text($ta, get_address_text($new))) {
- XDB::execute("UPDATE adresses
- SET adr1 = {?}, adr2 = {?}, adr3 = {?},
- cityid = {?}, city = {?}, postcode = {?},
- 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;
- }
- } else {
- $new['store'] = false;
- $erreur[$a['adrid']] = $new;
- }
- }
- return $erreur;
-}
-// }}}
-
-// {{{ synchro_city($id)
-/** synchronise the local geoloc_city base to geoloc.org
- * @param $id the id of the city to synchronize
- */
-function synchro_city($id)
-{
- 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);
- if ($s) {
- return XDB::execute("REPLACE INTO geoloc_city VALUES ".$s) > 0;
- }
-}
- // }}}
-
-// {{{ function fix_cities_not_on_map($limit)
-function fix_cities_not_on_map($limit=false, $cityid=false)
-{
- $missing = 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"
- . ($cityid ? " AND c.id = '" . $cityid . "'" : "" )
- . ($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, '')";
- }
- }
- if (strlen($values) > 1) {
- XDB::execute("REPLACE INTO geoloc_city_in_maps
- VALUES ".substr($values, 1));
- }
- } else {
- return false;
- }
- return true;
-}
-
-function set_smallest_levels()
-{
- $maxlengths = XDB::iterRow("SELECT MAX(LENGTH(gm.path)), gcim.city_id
- FROM geoloc_city_in_maps AS gcim
- INNER JOIN geoloc_maps AS gm USING ( map_id )
- GROUP BY gcim.city_id");
- while (list($length, $id) = $maxlengths->next()) {
- XDB::execute("UPDATE geoloc_city_in_maps AS gcim
- INNER JOIN geoloc_maps AS gm USING(map_id)
- SET gcim.infos = IF(LENGTH(gm.path) = {?}, 'smallest', '')
- WHERE gcim.city_id = {?}", $length, $id);
- }
- 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);
-}
-
-function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true)
-{
- if ($SFields instanceof UserSet) {
- $set = $SFields;
- $SFields = array();
- } else {
- $set = new UserSet();
- }
- for ($i_mapfield=0; $i_mapfield < count($SFields) ; $i_mapfield++) {
- if ($SFields[$i_mapfield]->fieldFormName == 'mapid') {
- break;
- }
- }
- $SFields[$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'),
- $mapid);
- $fields = new SFieldGroup(true, $SFields);
- $where = $fields->get_where_statement();
- $joins = $fields->get_select_statement();
- if ($where) {
- $where .= ' AND ';
- }
- $cityres = $set->get('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',
- "$joins
- LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)",
- $where . ($direct ? "gcim.infos = 'smallest'" : '1'),
- 'gc.id, gc.alias',
- 'pop DESC');
- foreach($cityres as $c) {
- 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;
- }
- }
-}
-
-function geoloc_getData_subcountries($mapid, $sin, $minentities)
-{
- $countries = array();
- $cities = array();
-
- if ($mapid === false) {
- $wheremapid = "WHERE gm.parent IS NULL";
- } else {
- $wheremapid = "WHERE gm.parent = {?}";
- }
- $submapres = 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::v('mapid',''));
-
- global $globals;
-
- while ($c = $submapres->next()) {
- $country = $c;
- $country['color'] = 0xFFFFFF;
- $country['swf'] = $globals->geoloc->webservice_url."maps/mercator/map_".$c['id'].".swf";
- $countries[$c['id']] = $country;
- }
-
- if ($mapid === false) {
- return array($countries, $cities);
- }
-
- geoloc_getData_subcities(Env::i('mapid'), $sin, $cities);
- $nbcities = count($cities);
- $nocity = $nbcities == 0;
- if ($sin instanceof UserSet) {
- $set = $sin;
- $SFields = array();
- } else {
- $set = new UserSet();
- $SFields = $sin;
- }
-
- for ($i_mapfield=0; $i_mapfield < count($SFields) ; $i_mapfield++) {
- if ($SFields[$i_mapfield]->fieldFormName == 'mapid') {
- break;
- }
- }
- $SFields[$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, $SFields);
- $where = $fields->get_where_statement();
- $joins = $fields->get_select_statement();
- $countryres = $set->get('map.map_id AS id,
- COUNT(u.user_id) AS nbPop,
- SUM(u.promo % 2) AS yellow,
- COUNT(DISTINCT gcim.city_id) AS nbCities,
- SUM(IF(u.user_id IS NULL,0,am.glng)) AS lonPop,
- SUM(IF(u.user_id IS NULL, 0,am.glat)) AS latPop',
- $joins,
- $where,
- 'map.map_id',
- 'NULL');
-
- $maxpop = 0;
- $nbentities = $nbcities + count($countryres);
- foreach ($countryres as $c) {
- $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 < $minentities){
- foreach($countries as $i => $c) {
- $countries[$i]['nbPop'] = 0;
- if (@$c['nbCities'] > 0) {
- geoloc_getData_subcities($c['id'], $sin, $cities, 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;
- }
- }
-
- return array($countries, $cities);
-}
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
$ret = '';
$tel_length = strlen($tel);
if((!isset($format['phoneprf'])) || ($format['phoneprf'] == '')) {
- $res = XDB::query("SELECT phoneprf, phoneformat AS format
- FROM geoloc_pays
- WHERE phoneprf = {?} OR phoneprf = {?} OR phoneprf = {?}
+ $res = XDB::query("SELECT phonePrefix AS phoneprf, phoneFormat AS format
+ FROM geoloc_countries
+ WHERE phonePrefix = {?} OR phonePrefix = {?} OR phonePrefix = {?}
LIMIT 1",
substr($tel, 0, 1), substr($tel, 0, 2), substr($tel, 0, 3));
if ($res->numRows() == 0) {
}
}
-class GeolocView implements PlView
-{
- private $set;
- private $type;
- private $params;
-
- public function __construct(PlSet &$set, $data, array $params)
- {
- $this->params = $params;
- $this->set =& $set;
- $this->type = $data;
- }
-
- private function use_map()
- {
- return is_file(dirname(__FILE__) . '/../modules/geoloc/dynamap.swf') &&
- is_file(dirname(__FILE__) . '/../modules/geoloc/icon.swf');
- }
-
- public function args()
- {
- $args = $this->set->args();
- unset($args['initfile']);
- unset($args['mapid']);
- return $args;
- }
-
- public function apply(PlPage &$page)
- {
- require_once 'geoloc.inc.php';
- require_once '../modules/search/search.inc.php';
-
- switch ($this->type) {
- case 'icon.swf':
- header("Content-type: application/x-shockwave-flash");
- header("Pragma:");
- readfile(dirname(__FILE__).'/../modules/geoloc/icon.swf');
- exit;
-
- case 'dynamap.swf':
- header("Content-type: application/x-shockwave-flash");
- header("Pragma:");
- readfile(dirname(__FILE__).'/../modules/geoloc/dynamap.swf');
- exit;
-
- case 'init':
- $page->changeTpl('geoloc/init.tpl', NO_SKIN);
- header('Content-Type: text/xml');
- header('Pragma:');
- if (!empty($GLOBALS['IS_XNET_SITE'])) {
- $page->assign('background', 0xF2E9D0);
- }
- break;
-
- case 'city':
- $page->changeTpl('geoloc/city.tpl', NO_SKIN);
- header('Content-Type: text/xml');
- header('Pragma:');
- $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
- $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, d.promo, al.alias',
- "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
- INNER JOIN profile_display AS d ON (d.pid = u.user_id)
- LEFT JOIN aliases AS al ON (u.user_id = al.id
- AND FIND_IN_SET('bestalias', al.flags))
- INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
- 'adrf.cityid = ' . Env::i('cityid'), null, null, 11);
- $page->assign('users', $it);
- break;
-
- case 'country':
- if (Env::has('debug')) {
- $page->changeTpl('geoloc/country.tpl', SIMPLE);
- } else {
- $page->changeTpl('geoloc/country.tpl', NO_SKIN);
- header('Content-Type: text/xml');
- header('Pragma:');
- }
- $mapid = Env::has('mapid') ? Env::i('mapid', -2) : false;
- list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set, 10);
- $page->assign('countries', $countries);
- $page->assign('cities', $cities);
- break;
-
- default:
- global $globals;
- if (!$this->use_map()) {
- $page->assign('request_geodesix', true);
- }
- $page->assign('annu', @$this->params['with_annu']);
- $page->assign('protocole', @$_SERVER['HTTPS'] ? 'https' : 'http');
- $this->set->get('u.user_id', null, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null);
- return 'include/plview.geoloc.tpl';
- }
- }
-}
-
class GadgetView implements PlView
{
public function __construct(PlSet &$set, $data, array $params)
u.perms != 'pending' AS wasinscrit,
u.deces != 0 AS dcd, u.deces,
FIND_IN_SET('femme', u.flags) AS sexe,
- adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
+ " // adr.city, gr.name AS region
+ . "gc.iso_3166_1_a2, gc.countryFR AS countrytxt" .
(S::logged() ? ", c.contact AS contact" : '');
}
public function joins()
{
- return "LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : "
- AND adr.pub = 'public'").")
- LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
- LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
- (S::logged() ?
- "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
- : "");
+ return "LEFT JOIN profile_addresses AS adr ON (u.user_id = adr.pid AND
+ FIND_IN_SET('current', adr.flags)"
+ . (S::logged() ? "" : "AND adr.pub = 'public'") . ")
+ LEFT JOIN geoloc_countries AS gc ON (adr.countryId = gc.iso_3166_1_a2)
+ LEFT JOIN geoloc_administrativeareas AS gr ON (adr.countryId = gr.country
+ AND adr.administrativeAreaId = gr.id)
+ " . (S::logged() ?
+ "LEFT JOIN contacts AS c ON (c.contact = u.user_id
+ AND c.uid = " . S::v('uid') . ")" : "");
}
public function apply(PlPage &$page)
parent::__construct($_user, false, 'medal', $_stamp);
$this->mid = $_idmedal;
$this->gid = $_subidmedal;
+ if (is_null($this->gid)) {
+ $this->gid = 0;
+ }
}
// }}}
register_watch_op($this->user->id(), WATCH_FICHE, '', 'medals');
return XDB::execute('REPLACE INTO profile_medals_sub
VALUES ({?}, {?}, {?})',
- $this->user->id(), $this->mid, $this->gid);
+ $this->user->id(), $this->mid,
+ is_null($this->gid) ? 0 : $this->gid);
}
// }}}
$error_mat = "You didn't provide me with a valid matricule number...";
$error_key = "You didn't provide me with a valid cipher key...";
-/**
- le premier parametre doit etre le matricule
- le second parametre facultatif doit etre le numero de l'adresse voulue :
- -1 => on ne veut pas d'adresse
- 0 => on veut toutes les adresses
- n => on veut l'adresse numero n
-
- IL NE FAUT PAS CHANGER LES NOMS DES CHAMPS DE ADRESSES
- S'IL Y A DES MODIFS A FAIRE VOIR AVEC MANAGEURS admin@manageurs.com
-*/
+
+// The first parameter has to be the identification number (matricule).
+// The second parameter facultative has to be the number of the desired address:
+// -1 => we do not want any address;
+// 0 => we want all the addresses;
+// n => we want the address number n.
+//
+// DO NOT CHANGE THE NAMES OF THE ADDRESSES' FIELDS.
+// IF YOU HAVE TO MAKE SOME MODIFICATION, FIRST CONTACT:
+// admin@manageurs.com
function get_annuaire_infos($method, $params) {
+ require "geocoding.inc.php";
global $error_mat, $error_key, $globals;
- //verif du mdp
- if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)){return false;}
- //si on a adresse == -1 => on ne recupère aucune adresse
- if(isset($params[2]) && ($params[2] == -1)) unset($params[2]);
-
- if( !empty($params[1]) ){ // on verifie qu'on a bien un matricule
+ // Password verification.
+ if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)) {
+ return false;
+ }
+ // If address == -1, we do not retrieve any address.
+ if(isset($params[2]) && ($params[2] == -1)) {
+ unset($params[2]);
+ }
- //on ne recupere pas les adresses inutilement
- if(!isset($params[2])){
+ // We check we actually have an identification number.
+ if(!empty($params[1])) {
+ // We only retrieve addresses when required.
+ if(!isset($params[2])) {
$res = XDB::iterRow(
"SELECT ph.display_tel AS cell, a.naissance AS age
FROM auth_user_md5 AS a
LEFT JOIN profile_phones AS ph ON (ph.uid = a.user_id AND link_type='user' AND tel_type = 'mobile')
WHERE a.matricule = {?} LIMIT 1", $params[1]);
$array = $res->next();
- }
- else{
+ } else {
$res = XDB::iterRow(
- "SELECT a.naissance AS age,
- adr.adr1, adr.adr2, adr.adr3,
- adr.postcode, adr.city, adr.country,
- adr.uid, adr.adrid
- FROM auth_user_md5 AS a
- INNER JOIN auth_user_quick AS q USING (user_id)
- LEFT JOIN adresses AS adr ON(adr.uid = a.user_id)
+ "SELECT a.naissance, addr.text, addr.postalCode,
+ l.name, addr.countryId, addr.pid, addr.id
+ FROM auth_user_md5 AS a
+ INNER JOIN auth_user_quick AS q USING (user_id)
+ LEFT JOIN profile_addresses AS addr ON(adr.pid = a.user_id)
+ LEFT JOIN geoloc_localities AS l ON (l.id = addr.localityId)
WHERE a.matricule = {?} AND
NOT FIND_IN_SET('pro', adr.statut)
ORDER BY NOT FIND_IN_SET('active', adr.statut),
FIND_IN_SET('res-secondaire', adr.statut),
NOT FIND_IN_SET('courrier', adr.statut)", $params[1]);
- //traitement des adresses si necessaire
- if(list($age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
- $adr['pays'], $uid, $adr['adrid']) = $res->next())
- {
- $sql = XDB::query("SELECT display_tel
- FROM profile_phones
- WHERE uid ={?} AND link_type = 'user' AND tel_type = 'mobile'
- LIMIT 1", $uid);
- if ($sql->numRows()>0) {
+ // Process the addresses we got.
+ if(list($age, $text, $adr['cp'], $adr['ville'],
+ $adr['pays'], $uid, $adr['adrid']) = $res->next()) {
+ list($adr['adr1'], $adr['adr2'], $adr['adr3']) =
+ explode("\n", Geocoder::getFirstLines($text, $adr['cp'], 3));
+ $sql = XDB::query("SELECT display_tel
+ FROM profile_phones
+ WHERE uid = {?} AND link_type = 'user' AND tel_type = 'mobile'
+ LIMIT 1", $uid);
+ if ($sql->numRows() > 0) {
$array['cell'] = $sql->fetchOneCell();
} else {
$array['cell'] ='';
$array['adresse'][] = $adr;
- //on clamp le numero au nombre d'adresses dispo
+ // We limit the address number by the number of available addresses.
$adresse = min((int) $params[2], $res->total());
- if ($adresse != 1) { //on ne veut pas la premiere adresse
+ if ($adresse != 1) { // We don't want the first address.
$i = 2;
- while(list($age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
- $adr['pays'], , $adr['adrid']) = $res->next())
- {
- if($adresse == $i){//si on veut cette adresse en particulier
+ while(list($age, $text, $adr['cp'], $adr['ville'],
+ $adr['pays'], , $adr['adrid']) = $res->next()) {
+ list($adr['adr1'], $adr['adr2'], $adr['adr3']) =
+ explode("\n", Geocoder::getFirstLines($text, $adr['cp'], 3));
+ if ($adresse == $i) {
+ // If we want this particular address.
$array['adresse'][0] = $adr;
//$res->free();
break;
- }
- elseif($adresse == 0){//si on veut toutes les adresses
+ } elseif ($adresse == 0) {
+ // If we want every address.
$array['adresse'][] = $adr;
}
$i++;
}
}
- // on rajoute les numéros de tél
+ // We add the phone numbers.
$adrid_index = array();
- foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i;
- // on rajoute les numéros de tels
+ foreach ($array['adresse'] as $i => $a) {
+ $adrid_index[$a['adrid']] = $i;
+ }
$restel = XDB::iterator(
- "SELECT t.display_tel AS tel, t.tel_type, t.link_id as adrid
- FROM profile_phones AS t
- INNER JOIN adresses AS a ON (t.link_id = a.adrid AND t.uid = a.uid)
- WHERE t.uid = {?} AND t.link_type = 'address' AND NOT FIND_IN_SET('pro', a.statut)", $uid);
- while ($tel = $restel->next()) $array['adresse'][$adrid_index[$tel['adrid']]]['tels'][] = $tel;
+ "SELECT t.display_tel AS tel, t.tel_type, t.link_id as adrid
+ FROM profile_phones AS t
+ INNER JOIN profile_addresses AS a ON (t.link_id = a.id AND t.uid = a.pid)
+ WHERE t.uid = {?} AND t.link_type = 'address'
+ AND NOT FIND_IN_SET('pro', a.statut)", $uid);
+ while ($tel = $restel->next()) {
+ $array['adresse'][$adrid_index[$tel['adrid']]]['tels'][] = $tel;
+ }
foreach ($array['adresse'] as $i => $adr) {
unset($lasttel);
- foreach($adr['tels'] as $j => $t){
- if (!isset($array['adresse'][$i]['tel']) && (strpos($t['tel_type'], 'Tél') === 0)) $array['adresse'][$i]['tel'] = $t['tel'];
- elseif (!isset($array['adresse'][$i]['fax']) && (strpos($t['tel_type'], 'Fax') === 0)) $array['adresse'][$i]['fax'] = $t['tel'];
- else $lasttel = $t['tel'];
- if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) break;
+ foreach ($adr['tels'] as $j => $t) {
+ if (!isset($array['adresse'][$i]['tel']) && (strpos($t['tel_type'], 'Tél') === 0)) {
+ $array['adresse'][$i]['tel'] = $t['tel'];
+ } elseif (!isset($array['adresse'][$i]['fax'])
+ && (strpos($t['tel_type'], 'Fax') === 0)) {
+ $array['adresse'][$i]['fax'] = $t['tel'];
+ } else {
+ $lasttel = $t['tel'];
+ }
+ if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) {
+ break;
+ }
}
- if (!isset($array['adresse'][$i]['tel']) && isset($lasttel))
+ if (!isset($array['adresse'][$i]['tel']) && isset($lasttel)) {
$array['adresse'][$i]['tel'] = $lasttel;
- elseif (!isset($array['adresse'][$i]['fax']) && isset($lasttel))
+ } elseif (!isset($array['adresse'][$i]['fax']) && isset($lasttel)) {
$array['adresse'][$i]['fax'] = $lasttel;
+ }
unset($array['adresse'][$i]['adrid']);
unset($array['adresse'][$i]['tels']);
}
- }
- else{
+ } else {
$array = false;
}
}
- if ($array) { // on a bien eu un résultat : le matricule etait bon
+ if ($array) { // We did get a result: the identification number was rigth.
- //on n'envoit que l'age à manageurs le format est YYYY-MM-DD 0123-56-89
- $year = (int) substr($array['age'],0,4);
- $month = (int) substr($array['age'],5,2);
- $day = (int) substr($array['age'],8,2);
+ // We only send the age to manageurs.com; the format is YYYY-MM-DD 0123-56-89.
+ $year = (int) substr($array['age'], 0, 4);
+ $month = (int) substr($array['age'], 5, 2);
+ $day = (int) substr($array['age'], 8, 2);
$age = (int) date('Y') - $year - 1;
if(( $month < (int)date('m')) ||
- (($month == (int)date('m')) && ($day >= (int)date('d'))))
- {
+ (($month == (int)date('m')) && ($day >= (int)date('d')))) {
$age += 1;
}
$array['age'] = $age;
- //on commence le cryptage des donnees
- if (manageurs_encrypt_init($params[1]) == 1) {//on a pas trouve la cle pour crypter
+ // We start the encryption of the data.
+ if (manageurs_encrypt_init($params[1]) == 1) {
+ // We did not find the key to encryptthe data.
$args = array("erreur" => 3, "erreurstring" => $error_key);
$reply = xmlrpc_encode_request(NULL,$args);
} else {
$reply = manageurs_encrypt_array($array);
manageurs_encrypt_close();
}
- } else {//le matricule n'etait pas valide
+ } else {
+ // The identification number was not valid.
$args = array("erreur" => 2, "erreurstring" => $erreur_mat);
$reply = xmlrpc_encode_request(NULL,$args);
}
- } else {//le matricule n'etait pas en argument
+ } else {
+ // The identification number was not in argument.
$args = array("erreur" => 1, "erreurstring" => $error_mat);
- $reply = xmlrpc_encode_request(NULL,$args);
+ $reply = xmlrpc_encode_request(NULL, $args);
}
return $reply;
function get_nouveau_infos($method, $params) {
global $error_mat, $error_key, $globals;
- //verif du mdp
- if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)){return false;}
- if( !empty($params[1]) ){ // on verifie qu'on a bien un matricule
-
+ // Password verification.
+ if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)) {
+ return false;
+ }
+ // We check we actually have an identification number.
+ if(!empty($params[1])) {
$res = XDB::query(
- "SELECT a.nom, a.nom_usage,a.prenom, FIND_IN_SET('femme', a.flags) as femme ,a.deces!= 0 as decede ,
- a.naissance, a.promo, concat(al.alias, '@m4x.org') as mail
- FROM auth_user_md5 AS a
- INNER JOIN aliases as al ON a.user_id=al.id
- WHERE al.flags='bestalias' and a.matricule = {?}",$params[1]);
+ "SELECT a.nom, a.nom_usage,a.prenom, FIND_IN_SET('femme', a.flags) as femme,
+ a.deces!= 0 as decede, a.naissance, a.promo, concat(al.alias, '@m4x.org') as mail
+ FROM auth_user_md5 AS a
+ INNER JOIN aliases AS al ON (a.user_id = al.id)
+ WHERE al.flags = 'bestalias' AND a.matricule = {?}",$params[1]);
$data=$res->fetchOneAssoc();
//$data['mail'].='@polytechnique.org';
- //on commence le cryptage des donnees
- if (manageurs_encrypt_init($params[1]) == 1) {//on a pas trouve la cle pour crypter
+ // We start the encryption of the data.
+ if (manageurs_encrypt_init($params[1]) == 1) {
+ // We did not find the key to encryptthe data.
$args = array("erreur" => 3, "erreurstring" => $error_key);
- $reply = xmlrpc_encode_request(NULL,$args);
+ $reply = xmlrpc_encode_request(NULL, $args);
} else {
$reply = manageurs_encrypt_array($data);
manageurs_encrypt_close();
}
+ } else {
+ $reply = false;
}
- else{
- $reply=false;
- }
- return $reply;
-
+ return $reply;
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
$page->assign('photo_incitation', $res->fetchOneCell() == 0);
// Geo-location onebox.
- require_once 'geoloc.inc.php';
- $res = localize_addresses(S::user()->id());
- $page->assign('geoloc_incitation', count($res));
+ require_once "geocoding.inc.php";
+ $page->assign('geoloc_incitation', Geocoder::countNonGeocoded(S::user()->id()));
// Direct link to the RSS feed, when available.
if (S::hasAuthToken()) {
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2009 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 *
- ***************************************************************************/
-
-class GeolocModule extends PLModule
-{
- function handlers()
- {
- return array(
- 'geoloc' => $this->make_hook('default', AUTH_COOKIE),
- 'admin/geoloc' => $this->make_hook('admin', AUTH_MDP, 'admin'),
- 'admin/geoloc/dynamap' => $this->make_hook('admin_dynamap', AUTH_MDP, 'admin'),
- 'admin/geoloc/country' => $this->make_hook('admin_country', AUTH_MDP, 'admin')
- );
- }
-
- function handler_default(&$page, $action = null, $subaction = null)
- {
- global $globals;
-
- $set = new UserSet();
- $set->addMod('geoloc', 'Geolocalisation', true);
- $set->apply('geoloc', $page, $action, $subaction);
- }
-
- function handler_admin(&$page, $action = false) {
- $page->changeTpl('geoloc/admin.tpl');
- require_once("geoloc.inc.php");
- $page->setTitle('Administration - Geolocalisation');
-
- $nb_synchro = 0;
-
- if (Env::has('id') && is_numeric(Env::v('id'))) {
- if (synchro_city(Env::v('id'))) $nb_synchro ++;
- }
-
- if ($action == 'missinglat') {
- $res = XDB::iterRow("SELECT id FROM geoloc_city WHERE lat = 0 AND lon = 0");
- while ($a = $res->next()) if (synchro_city($a[0])) $nb_synchro++;
- }
-
- if ($nb_synchro)
- $page->trigSuccess(($nb_synchro > 1)?($nb_synchro." villes ont été synchronisées"):"Une ville a été synchronisée");
-
- $res = XDB::query("SELECT COUNT(*) FROM geoloc_city WHERE lat = 0 AND lon = 0");
- $page->assign("nb_missinglat", $res->fetchOneCell());
- }
-
- function handler_admin_dynamap(&$page, $action = false) {
- $page->changeTpl('geoloc/admin_dynamap.tpl');
-
- if ($action == 'cities_not_on_map') {
- require_once('geoloc.inc.php');
- if (!fix_cities_not_on_map(20))
- $page->trigError("Impossible d'accéder au webservice");
- else
- $refresh = true;
- }
-
- if ($action == 'smallest_maps') {
- require_once('geoloc.inc.php');
- set_smallest_levels();
- }
-
- if ($action == 'precise_coordinates') {
- XDB::execute("UPDATE adresses AS a
- INNER JOIN geoloc_city AS c ON(a.cityid = c.id)
- SET a.glat = c.lat / 100000, a.glng = c.lon / 100000");
- }
-
- if ($action == 'newmaps') {
- require_once('geoloc.inc.php');
- if (!get_new_maps(Env::v('url')))
- $page->trigError("Impossible d'accéder aux nouvelles cartes");
- }
-
- $countMissing = 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");
- $missing = $countMissing->fetchOneCell();
-
- $countNoSmallest = XDB::query("SELECT SUM(IF(infos = 'smallest',1,0)) AS n FROM geoloc_city_in_maps GROUP BY city_id ORDER BY n");
- $noSmallest = $countNoSmallest->fetchOneCell() == 0;
-
- $countNoCoordinates = XDB::query("SELECT COUNT(*) FROM adresses WHERE cityid IS NOT NULL AND glat = 0 AND glng = 0");
- $noCoordinates = $countNoCoordinates->fetchOneCell();
-
- if (isset($refresh) && $missing) {
- $page->assign("pl_extra_header", "<meta http-equiv='Refresh' content='3'/>");
- }
- $page->assign("nb_cities_not_on_map", $missing);
- $page->assign("no_smallest", $noSmallest);
- $page->assign("no_coordinates", $noCoordinates);
- }
-
- function handler_admin_country(&$page, $action = 'list', $id = null)
- {
- $page->assign('xorg_title', 'Polytechnique.org - Administration - Pays');
- $page->assign('title', 'Gestion des pays');
- $table_editor = new PLTableEditor('admin/geoloc/country', 'geoloc_pays', 'a2', true);
- $table_editor->describe('a2', 'alpha-2', true);
- $table_editor->describe('a3', 'alpha-3', false);
- $table_editor->describe('n3', 'ISO numeric', false);
- $table_editor->describe('num', 'num', false);
- $table_editor->describe('worldrgn', 'Continent', false);
- $table_editor->describe('subd', 'Subdivisions territoriales', false);
- $table_editor->describe('post', 'post', false);
- $table_editor->describe('pays', 'Nom (fr)', true);
- $table_editor->describe('country', 'Nom (en)', true);
- $table_editor->describe('phoneprf', 'Préfixe téléphonique', true);
- $table_editor->describe('phoneformat', 'Format du téléphone (ex: (+p) ### ## ## ##)', false);
- $table_editor->describe('capital', 'Capitale', true);
- $table_editor->describe('nat', 'Nationalité', true);
- $table_editor->describe('display', 'Format des adresses', false);
-
- if ($action == 'update') {
- if (Post::has('a2') && (Post::v('a2') == $id) && Post::has('phoneprf') && (Post::v('phoneprf') != '')) {
- if (Post::has('phoneformat')) {
- $new_format = Post::v('phoneformat');
- } else {
- $new_format = '';
- }
- $res = XDB::query("SELECT phoneformat
- FROM geoloc_pays
- WHERE phoneprf = {?}
- LIMIT 1",
- Post::v('phoneprf'));
- $old_format = $res->fetchOneCell();
- if ($new_format != $old_format) {
- require_once("profil.func.inc.php");
- XDB::execute("UPDATE geoloc_pays
- SET phoneformat = {?}
- WHERE phoneprf = {?}",
- $new_format, Post::v('phoneprf'));
- }
- }
- }
- $table_editor->apply($page, $action, $id);
- }
-
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
class PayPal
{
- // {{{ properties
-
var $val_number;
var $urlform;
var $nomsite = "PayPal";
var $infos;
- // }}}
- // {{{ constructor
-
function PayPal($val)
{
$this->val_number = $val;
}
- // }}}
- // {{{ function form()
-
function prepareform(&$pay)
{
- // toute la doc sur :
- // https://www.paypal.com/fr_FR/pdf/integration_guide.pdf
- // attention : le renvoi automatique ne fonctionne que si
- // on oblige les gens à créer un compte paypal
- // nous ne l'utilisons pas ; il faut donc que l'utilisateur
- // revienne sur le site
+ // Documentation:
+ // https://www.paypal.com/developer
+ // Warning: the automatic return only works if we force the
+ // users to create a paypal account. We do not use it; thus
+ // the user must come back on the site.
global $globals, $platal;
- $this->urlform = 'https://'.$globals->money->paypal_site.'/cgi-bin/webscr';
+ $this->urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr';
$user = S::user();
$name = $user->lastName();
$roboturl = str_replace("https://","http://",$globals->baseurl)
- . '/' . $platal->ns . "payment/paypal_return/".S::v('uid')."?comment=".urlencode(Env::v('comment'));
+ . '/' . $platal->ns . "payment/paypal_return/" . S::v('uid')
+ . "?comment=" . urlencode(Env::v('comment'));
- $this->infos = Array();
+ $this->infos = array();
- $this->infos['commercant'] = Array(
+ $this->infos['commercant'] = array(
'business' => $globals->money->paypal_compte,
- 'rm' => 2,
+ 'rm' => 2,
'return' => $roboturl,
- 'cn' => 'Commentaires',
+ 'cn' => 'Commentaires',
'no_shipping' => 1,
'cbt' => empty($GLOBALS['IS_XNET_SITE']) ?
- 'Revenir sur polytechnique.org' :
- 'Revenir sur polytechnique.net');
+ 'Revenir sur polytechnique.org.' :
+ 'Revenir sur polytechnique.net.'
+ );
- $info_client = Array(
+ $info_client = array(
'first_name' => S::v('prenom'),
'last_name' => $name,
- 'email' => S::user()->bestEmail());
+ 'email' => S::user()->bestEmail()
+ );
// XXX: waiting for port of adresses.
$res = XDB::query(
- "SELECT a.adr1 AS address1, a.adr2 AS address2,
- a.city, a.postcode AS zip, a.country,
- IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
- FROM auth_user_quick AS q
- LEFT JOIN adresses AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut))
- LEFT JOIN profile_phones AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address' AND t1.link_id = a.adrid)
- LEFT JOIN profile_phones AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user' AND t2.link_id = 0)
- WHERE q.user_id = {?}
- LIMIT 1", S::v('uid'));
+ "SELECT a.text, l.name AS city, a.postalCode AS zip, a.countryiId AS country,
+ IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
+ FROM auth_user_quick AS q
+ LEFT JOIN profile_addresses AS a ON (q.user_id = a.pid AND FIND_IN_SET('current', a.flags))
+ LEFT JOIN profile_phones AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address'
+ AND t1.link_id = a.adrid)
+ LEFT JOIN profile_phones AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user'
+ AND t2.link_id = 0)
+ LEFT JOIN geoloc_localities AS l ON (l.id = a.localityId)
+ WHERE q.user_id = {?}
+ LIMIT 1",
+ S::v('uid'));
$this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
-
- // on constuit la reference de la transaction
- $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
- $fullref = substr("$prefix-xorg-{$pay->id}",-15);
-
- $this->infos['commande'] = Array(
- 'item_name' => replace_accent($pay->text),
- 'amount' => $this->val_number,
+ list($this->infos['client']['address1'], $this->infos['client']['address2']) =
+ explode("\n", Geocoder::getFirstLines($this->infos['client']['text'],
+ $this->infos['client']['zip'], 2));
+ unset($this->infos['client']['text']);
+
+ // We build the transaction's reference
+ $prefix = ($pay->flags->hasflag('unique')) ? str_pad("", 15, "0") : rand_url_id();
+ $fullref = substr("$prefix-xorg-{$pay->id}", -15);
+
+ $this->infos['commande'] = array(
+ 'item_name' => replace_accent($pay->text),
+ 'amount' => $this->val_number,
'currency_code' => 'EUR',
- 'custom' => $fullref);
+ 'custom' => $fullref
+ );
- $this->infos['divers'] = Array('cmd' => '_xclick');
+ $this->infos['divers'] = array('cmd' => '_xclick');
}
-
- // }}}
}
$api = 'PayPal';
$page->assign('medal_list', $mlist);
}
- function handler_ajax_address(&$page, $adid)
+ function handler_ajax_address(&$page, $id)
{
header('Content-Type: text/html; charset=utf-8');
$page->changeTpl('profile/adresses.address.tpl', NO_SKIN);
- $page->assign('i', $adid);
- $page->assign('adr', array());
+ $page->assign('i', $id);
+ $page->assign('address', array());
}
function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
$page->assign_by_ref('secteurs', $secteurs);
$page->assign_by_ref('ss_secteurs', $ss_secteurs);
- //pays
- $res = XDB::query('SELECT gp.pays
- FROM profile_mentor_country AS m
- LEFT JOIN geoloc_pays AS gp ON (m.country = gp.a2)
- WHERE uid = {?}', $user->id());
+ // Countries.
+ $res = XDB::query(
+ "SELECT gc.countryFR
+ FROM profile_mentor_country AS m
+ LEFT JOIN geoloc_countries AS gc ON (m.country = gc.iso_3166_1_a2)
+ WHERE uid = {?}", $user->id());
$page->assign('pays', $res->fetchColumn());
$page->addJsLink('close_on_esc.js');
$page->changeTpl('include/field.select.tpl', NO_SKIN);
$page->assign('name', 'pays_sel');
$where = ($ssect ? ' AND ms.subsectorid = {?}' : '');
- $it = XDB::iterator("SELECT a2 AS id, pays AS field
- FROM geoloc_pays AS g
- INNER JOIN profile_mentor_country AS mp ON (mp.country = g.a2)
+ $it = XDB::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.countryFR AS field
+ FROM geoloc_countries AS gc
+ INNER JOIN profile_mentor_country AS mp ON (mp.country = gc.iso_3166_1_a2)
INNER JOIN profile_mentor_sector AS ms ON (ms.uid = mp.uid)
- WHERE ms.sectorid = {?} $where
- GROUP BY a2
- ORDER BY pays", $sect, $ssect);
+ WHERE ms.sectorid = {?} " . $where . "
+ GROUP BY iso_3166_1_a2
+ ORDER BY countryFR", $sect, $ssect);
$page->assign('list', $it);
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class ProfileAddress extends ProfileGeoloc
+class ProfileAddress extends ProfileGeocoding
{
private $bool;
private $pub;
$this->pub = new ProfilePub();
}
- private function cleanAddress(ProfilePage &$page, $adrid, array &$address, &$success)
+ private function cleanAddress(ProfilePage &$page, $addrid, array &$address)
{
- if (@$address['changed']) {
- $address['datemaj'] = time();
- }
- $success = true;
if (!isset($address['tel'])) {
$address['tel'] = array();
}
- $profiletel = new ProfilePhones('address', $adrid);
- $address['tel'] = $profiletel->value($page, 'tel', $address['tel'], $s);
- $address['checked'] = $this->bool->value($page, 'checked', $address['checked'], $s);
- $address['secondaire'] = $this->bool->value($page, 'secondaire', $address['secondaire'], $s);
- $address['mail'] = $this->bool->value($page, 'mail', $address['mail'], $s);
+ $profiletel = new ProfilePhones('address', $addrid);
+ $address['tel'] = $profiletel->value($page, 'tel', $address['tel'], $s);
+ $address['current'] = $this->bool->value($page, 'current', $address['current'], $s);
$address['temporary'] = $this->bool->value($page, 'temporary', $address['temporary'], $s);
- $address['current'] = $this->bool->value($page, 'current', @$address['current'], $s);
- $address['pub'] = $this->pub->value($page, 'pub', $address['pub'], $s);
- unset($address['parsevalid']);
- unset($address['changed']);
- unset($address['removed']);
- unset($address['display']);
+ $address['secondary'] = $this->bool->value($page, 'secondary', $address['secondary'], $s);
+ $address['mail'] = $this->bool->value($page, 'mail', $address['mail'], $s);
+ $address['pub'] = $this->pub->value($page, 'pub', $address['pub'], $s);
}
public function value(ProfilePage &$page, $field, $value, &$success)
$init = false;
if (is_null($value)) {
$value = $page->values['addresses'];
- $init = true;
+ $init = true;
}
- foreach ($value as $key=>&$adr) {
- if (@$adr['removed']) {
+ foreach ($value as $key => &$address) {
+ if (isset($address['removed']) && $address['removed']) {
unset($value[$key]);
}
}
$current = 0;
$success = true;
- foreach ($value as $key=>&$adr) {
- if (@$adr['current']) {
+ foreach ($value as $key => &$address) {
+ if (isset($address['current']) && $address['current']) {
$current++;
}
}
if ($current == 0 && count($value) > 0) {
- foreach ($value as $key=>&$adr) {
- $adr['current'] = true;
+ foreach ($value as $address) {
+ $address['current'] = true;
break;
}
- } else if ($current > 1) {
+ } elseif ($current > 1) {
$success = false;
}
- foreach ($value as $key=>&$adr) {
- $ls = true;
- $this->geolocAddress($adr, $s);
- $ls = ($ls && $s);
- $this->cleanAddress($page, $key, $adr, $s);
- $ls = ($ls && $s);
- if (!trim($adr['text'])) {
+ foreach ($value as $key => &$address) {
+ if (!trim($address['text'])) {
unset($value[$key]);
- } else if (!$init) {
- $success = ($success && $ls);
+ } elseif (!$init) {
+ $this->geocodeAddress($address, $s);
+ $success = $success && $s;
}
+ $this->cleanAddress($page, $key, $address);
}
return $value;
}
private function saveAddress($pid, $adrid, array &$address)
{
+ require_once "geocoding.inc.php";
+
$flags = new PlFlagSet();
- $flags->addFlag('res-secondaire', $address['secondaire']);
- $flags->addFlag('courrier', $address['mail']);
- $flags->addFlag('temporaire', $address['temporary']);
- $flags->addFlag('active', $address['current']);
- $flags->addFlag('coord-checked', $address['checked']);
- XDB::execute("INSERT INTO adresses (adr1, adr2, adr3,
- postcode, city, cityid,
- country, region, regiontxt,
- pub, datemaj, statut,
- uid, adrid, glat, glng, comment)
- VALUES ({?}, {?}, {?},
- {?}, {?}, {?},
- {?}, {?}, {?},
- {?}, FROM_UNIXTIME({?}), {?},
- {?}, {?}, {?}, {?}, {?})",
- $address['adr1'], $address['adr2'], $address['adr3'],
- $address['postcode'], $address['city'], $address['cityid'],
- $address['country'], $address['region'], $address['regiontxt'],
- $address['pub'], $address['datemaj'], $flags,
- $pid, $adrid, $address['precise_lat'], $address['precise_lon'], $address['comment']);
+ $flags->addFlag('current', $address['current']);
+ $flags->addFlag('temporary', $address['temporary']);
+ $flags->addFlag('secondary', $address['secondary']);
+ $flags->addFlag('mail', $address['mail']);
+ $flags->addFlag('cedex', $address['cedex'] =
+ (strpos(strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"),
+ array("", "\n"), $address['text'])), 'CEDEX')) !== false);
+ Geocoder::getAreaId($address, "administrativeArea");
+ Geocoder::getAreaId($address, "subAdministrativeArea");
+ Geocoder::getAreaId($address, "locality");
+ XDB::execute("INSERT INTO profile_addresses (pid, type, id, flags, accuracy,
+ text, postalText, postalCode, localityId,
+ subAdministrativeAreaId, administrativeAreaId,
+ countryId, latitude, longitude, updateTime, pub, comment,
+ north, south, east, west)
+ VALUES ({?}, 'home', {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?},
+ {?}, {?}, FROM_UNIXTIME({?}), {?}, {?}, {?}, {?}, {?}, {?})",
+ $pid, $addrid, $flags, $address['accuracy'],
+ $address['text'], $address['postalText'], $address['postalCode'], $address['localityId'],
+ $address['subAdministrativeAreaId'], $address['administrativeAreaId'],
+ $address['countryId'], $address['latitude'], $address['longitude'],
+ $address['updateTime'], $address['pub'], $address['comment'],
+ $address['north'], $address['south'], $address['east'], $address['west']);
}
public function save(ProfilePage &$page, $field, $value)
{
- XDB::execute("DELETE FROM adresses
- WHERE uid = {?}",
+ XDB::execute("DELETE FROM profile_addresses
+ WHERE pid = {?} AND type = 'home'",
$page->pid());
XDB::execute("DELETE FROM profile_phones
WHERE uid = {?} AND link_type = 'address'",
$page->pid());
- foreach ($value as $adrid=>&$address) {
- $this->saveAddress($page->pid(), $adrid, $address);
- $profiletel = new ProfilePhones('address', $adrid);
+ foreach ($value as $addrid => &$address) {
+ $this->saveAddress($page->pid(), $addrid, $address);
+ $profiletel = new ProfilePhones('address', $addrid);
$profiletel->saveTels($page->pid(), 'tel', $address['tel']);
}
}
{
parent::__construct($wiz);
$this->settings['addresses'] = new ProfileAddress();
- $this->watched['addresses'] = true;
+ $this->watched['addresses'] = true;
}
protected function _fetchData()
{
- // Build the addresses tree
- $res = XDB::query("SELECT a.adrid AS id, a.adr1, a.adr2, a.adr3,
- UNIX_TIMESTAMP(a.datemaj) AS datemaj,
- a.postcode, a.city, a.cityid, a.region, a.regiontxt,
- a.pub, a.country, gp.pays AS countrytxt, gp.display,
- FIND_IN_SET('coord-checked', a.statut) AS checked,
- FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
- FIND_IN_SET('courrier', a.statut) AS mail,
- FIND_IN_SET('temporaire', a.statut) AS temporary,
- FIND_IN_SET('active', a.statut) AS current,
- a.glat AS precise_lat, a.glng AS precise_lon,
- a.comment
- FROM adresses AS a
- INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
- WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut)
- ORDER BY adrid",
+ $res = XDB::query("SELECT type, id, accuracy, text, postalText,
+ postalCode, localityId, subAdministrativeAreaId, administrativeAreaId,
+ countryId, latitude, longitude, pub, comment, updateTime,
+ north, south, east, west,
+ FIND_IN_SET('current', flags) AS current,
+ FIND_IN_SET('temporary', flags) AS temporary,
+ FIND_IN_SET('secondary', flags) AS secondary,
+ FIND_IN_SET('mail', flags) AS mail,
+ FIND_IN_SET('cedex', flags) AS cedex
+ FROM profile_addresses
+ WHERE pid = {?} AND type = 'home'
+ ORDER BY id",
$this->pid());
if ($res->numRows() == 0) {
$this->values['addresses'] = array();
$this->values['addresses'] = $res->fetchAllAssoc();
}
- $res = XDB::iterator("SELECT link_id AS adrid, tel_type AS type, pub, display_tel AS tel, comment
+ $res = XDB::iterator("SELECT link_id AS addrid, tel_type AS type, pub, display_tel AS tel, comment
FROM profile_phones
WHERE uid = {?} AND link_type = 'address'
ORDER BY link_id",
$i = 0;
$adrNb = count($this->values['addresses']);
while ($tel = $res->next()) {
- $adrid = $tel['adrid'];
- unset($tel['adrid']);
+ $adrid = $tel['addrid'];
+ unset($tel['addrid']);
while ($i < $adrNb && $this->values['addresses'][$i]['id'] < $adrid) {
$i++;
}
$address['tel'][] = $tel;
}
}
- foreach ($this->values['addresses'] as $id=>&$address) {
+ foreach ($this->values['addresses'] as $id => &$address) {
if (!isset($address['tel'])) {
$address['tel'] = array();
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class ProfileJob extends ProfileGeoloc
+class ProfileJob extends ProfileGeocoding
{
private $pub;
private $mail_new;
}
foreach ($value as $key=>&$job) {
$ls = true;
- $this->geolocAddress($job['w_adr'], $s);
+ $this->geocodeAddress($job['w_adr'], $s);
$ls = ($ls && $s);
$this->cleanJob($page, $key, $job, $s);
$ls = ($ls && $s);
$res = XDB::iterRow("SELECT j.id, je.name, j.functionid, j.sectorid, j.subsectorid,
j.subsubsectorid, j.description, e.adr1, e.adr2, e.adr3,
e.postcode, e.city, e.cityid, e.region, e.regiontxt,
- e.country, gp.pays, gp.display,
- FIND_IN_SET('geoloc', flags),
+ e.country, gc.countryFR, pa.accuracy,
j.email, j.url, j.pub,
e.adr_pub, j.email_pub,
e.glat, e.glng, s.name
FROM profile_job AS j
LEFT JOIN profile_job_enum AS je ON (j.jobid = je.id)
LEFT JOIN entreprises AS e ON (j.uid = e.uid AND j.id = e.entrid)
- LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.country)
+ LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = e.country)
LEFT JOIN profile_job_subsubsector_enum AS s ON (s.id = j.subsubsectorid)
WHERE j.uid = {?}
ORDER BY entrid", $this->pid());
$this->values['jobs'] = array();
while (list($id, $name, $function, $secteur, $ss_secteur, $sss_secteur, $description,
$w_adr1, $w_adr2, $w_adr3, $w_postcode, $w_city, $w_cityid,
- $w_region, $w_regiontxt, $w_country, $w_countrytxt, $w_display,
+ $w_region, $w_regiontxt, $w_country, $w_countrytxt,
$w_checked, $w_email, $w_web,
$pub, $w_adr_pub, $w_email_pub, $w_glat, $w_glng, $sss_secteur_name
) = $res->next()) {
'regiontxt' => $w_regiontxt,
'country' => $w_country,
'countrytxt' => $w_countrytxt,
- 'display' => $w_display,
'pub' => $w_adr_pub,
- 'checked' => $w_checked,
+ 'checked' => (($w_checked == 0)? true : false),
'precise_lat' => $w_glat,
'precise_lon' => $w_glng),
'w_email' => $w_email,
$success = true;
if (is_null($value)) {
$value = array();
- $res = XDB::iterRow("SELECT m.country, p.pays
+ $res = XDB::iterRow("SELECT m.country, gc.countryFR
FROM profile_mentor_country AS m
- INNER JOIN geoloc_pays AS p ON (m.country = p.a2)
+ INNER JOIN geoloc_countries AS gc ON (m.country = gc.iso_3166_1_a2)
WHERE m.uid = {?}",
$page->pid());
while (list($id, $name) = $res->next()) {
{
$page->assign('secteurs_sel', XDB::iterator("SELECT id, name AS label
FROM profile_job_sector_enum"));
+
+ $page->assign('countryList', XDB::iterator("SELECT iso_3166_1_a2, countryFR
+ FROM geoloc_countries
+ ORDER BY countryFR"));
}
}
if (is_null($value)) {
return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
}
- if (is_null($value) || !$value) {
+ if (!$value) {
$value = 'private';
- } else if ($value == 'on') { // Checkbox
+ } elseif ($value == 'on') { // Checkbox
$value = 'public';
}
return $value;
{
$success = true;
if (is_null($value)) {
- $value = @$page->values[$field];
+ $value = isset($page->values[$field]) ? $page->values[$field] : null;
}
return $value ? "1" : "";
}
}
}
-abstract class ProfileGeoloc implements ProfileSetting
+abstract class ProfileGeocoding implements ProfileSetting
{
- protected function geolocAddress(array &$address, &$success)
+ protected function geocodeAddress(array &$address, &$success)
{
- require_once 'geoloc.inc.php';
+ require_once 'geocoding.inc.php';
$success = true;
- unset($address['geoloc']);
- unset($address['geoloc_cityid']);
- if (@$address['parsevalid']
- || (@$address['text'] && @$address['changed'])
- || (@$address['text'] && !@$address['cityid'])) {
- $address = array_merge($address, empty_address());
- $new = get_address_infos(@$address['text']);
- if (compare_addresses_text(@$address['text'], $geotxt = get_address_text($new))
- || (@$address['parsevalid'] && @$address['cityid'])) {
- $address = array_merge($address, $new);
- $address['checked'] = true;
- } else if (@$address['parsevalid']) {
- $address = array_merge($address, cut_address(@$address['text']));
- $address['checked'] = true;
+ if ($address['changed'] == 1) {
+ $gmapsGeocoder = new GMapsGeocoder();
+ $address = $gmapsGeocoder->getGeocodedAddress($address);
+ if (isset($address['geoloc'])) {
+ $success = false;
+ }
+ }
+ if (isset($address['geoloc_choice'])) {
+ if ($address['geoloc_choice'] == 0) {
$mailer = new PlMailer('geoloc/geoloc.mail.tpl');
- $mailer->assign('text', get_address_text($address));
- $mailer->assign('geoloc', $geotxt);
+ $mailer->assign('text', $address['text']);
+ $mailer->assign('geoloc', $address['geoloc']);
$mailer->send();
- } else if (@$address['changed'] || !@$address['checked']) {
- $success = false;
- $address = array_merge($address, cut_address(@$address['text']));
- $address['checked'] = false;
- $address['geoloc'] = $geotxt;
- $address['geoloc_cityid'] = $new['cityid'];
- } else {
- $address = array_merge($address, cut_address(@$address['text']));
- $address['checked'] = true;
}
+ $gmapsGeocoder = new GMapsGeocoder();
+ $address = $gmapsGeocoder->stripGeocodingFromAddress($address);
}
- $address['precise_lat'] = rtrim($address['precise_lat'], '.0');
- $address['precise_lon'] = rtrim($address['precise_lon'], '.0');
- $address['text'] = get_address_text($address);
}
}
$this->form_prepare();
} else {
$textFields = array(
- 'country' => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'pays', 'exact' => false),
+ 'country' => array('field' => 'iso_3166_1_a2', 'table' => 'geoloc_countries', 'text' => 'countryFR',
+ 'exact' => false),
'fonction' => array('field' => 'id', 'table' => 'fonctions_def', 'text' => 'fonction_fr', 'exact' => true),
'secteur' => array('field' => 'id', 'table' => 'profile_job_sector_enum', 'text' => 'name', 'exact' => false),
- 'nationalite' => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'nat', 'exact' => 'false'),
+ 'nationalite' => array('field' => 'iso_3166_1_a2', 'table' => 'geoloc_countries',
+ 'text' => 'nationalityFR', 'exact' => 'false'),
'binet' => array('field' => 'id', 'table' => 'binets_def', 'text' => 'text', 'exact' => false),
'networking_type' => array('field' => 'network_type', 'table' => 'profile_networking_enum',
'text' => 'name', 'exact' => false),
'exact' => false),
'section' => array('field' => 'id', 'table' => 'sections', 'text' => 'text', 'exact' => false),
'school' => array('field' => 'id', 'table' => 'profile_education_enum', 'text' => 'name', 'exact' => false),
- 'city' => array('table' => 'geoloc_city', 'text' => 'name', 'exact' => false)
+ 'city' => array('table' => 'geoloc_localities', 'text' => 'name', 'exact' => false)
);
if (!Env::has('page')) {
S::logger()->log('search', 'adv=' . var_export($_GET, true));
$realid = 'profile_networking_enum.network_type';
break;
case 'city':
- $db = 'geoloc_city INNER JOIN
- adresses ON(geoloc_city.id = adresses.cityid)';
- $unique='uid';
- $field='geoloc_city.name';
+ $db = 'geoloc_localities INNER JOIN
+ profile_addresses ON (geoloc_localities.id = profile_addresses.localityId)';
+ $unique = 'uid';
+ $field ='geoloc_localities.name';
break;
case 'countryTxt':
- $db = 'geoloc_pays INNER JOIN
- adresses ON(geoloc_pays.a2 = adresses.country)';
- $unique = 'uid';
- $field = 'geoloc_pays.pays';
- $field2 = 'geoloc_pays.country';
- $realid = 'geoloc_pays.a2';
+ $db = 'geoloc_countries INNER JOIN
+ profile_addresses ON (geoloc_countries.iso_3166_1_a2 = profile_addresses.countryId)';
+ $unique = 'pid';
+ $field = 'geoloc_countries.countryFR';
+ $realid = 'geoloc_countries.iso_3166_1_a2';
break;
case 'entreprise':
$db = 'profile_job_enum INNER JOIN
$unique = 'm.uid';
break;
case 'nationaliteTxt':
- $db = 'geoloc_pays AS acgp
- INNER JOIN profiles AS acp ON (acgp.a2 IN (acp.nationality1, acp.nationality2, acp.nationality3))';
- $field = 'IF(acgp.nat = \'\', acgp.pays, acgp.nat)';
- $realid = 'acgp.a2';
+ $db = 'geoloc_countries INNER JOIN
+ profile ON (geoloc_countries.a2 IN (profile.nationality1, profile.nationality2, profile.nationality3))';
+ $field = 'geoloc_countries.nationalityFR';
+ $realid = 'geoloc_countries.iso_3166_1_a2';
break;
case 'description':
$db = 'profile_job';
$id = 'network_type';
break;
case 'country':
- $db = 'geoloc_pays';
- $field = 'pays';
- $id = 'a2';
+ $db = 'geoloc_countries';
+ $field = 'countryFR';
+ $id = 'iso_3166_1_a2';
$page->assign('onchange', 'changeCountry(this.value)');
break;
case 'fonction':
$field = 'nom';
break;
case 'nationalite':
- $db = 'geoloc_pays AS acgp INNER JOIN
+ $db = 'geoloc_countries INNER JOIN
profiles AS acp ON (acgp.a2 IN (acp.nationality1, acp.nationality2, acp.nationality3))';
- $field = 'IF(acgp.nat=\'\', acgp.pays, acgp.nat)';
- $id = 'acgp.a2';
+ $field = 'nationalityFR';
+ $id = 'iso_3166_1_a2';
break;
case 'region':
- $db = 'geoloc_region';
+ $db = 'geoloc_administrativeareas';
$field = 'name';
- $id = 'region';
+ $id = 'id';
if (isset($_REQUEST['country'])) {
- $where .= ' WHERE a2 = "'.$_REQUEST['country'].'"';
+ $where .= ' WHERE country = "' . $_REQUEST['country'] . '"';
}
break;
case 'school':
IF(e.pub='public', je.name, '') AS entreprise,
IF(nw.pub='public', nw.address, '') AS networking_address,
IF(nw.pub='public', nwe.name, '') AS networking_name,";
-@$globals->search->result_where_statement = '
+@$globals->search->result_where_statement = "
LEFT JOIN profile_education AS edu0 ON (u.user_id = edu0.uid AND edu0.id = 0)
LEFT JOIN profile_education_enum AS ede0 ON (ede0.id = edu0.eduid)
LEFT JOIN profile_education_degree_enum AS edd0 ON (edd0.id = edu0.degreeid)
LEFT JOIN profile_job_enum AS ee ON (e.jobid = ee.id)
LEFT JOIN profile_job_sector_enum AS es ON (es.id = e.sectorid)
LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
- LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2)
- LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2)
- LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2)
- LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
- LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
- LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
- LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')
+ LEFT JOIN geoloc_countries AS n1 ON (u.nationalite = n1.iso_3166_1_a2)
+ LEFT JOIN geoloc_countries AS n2 ON (u.nationalite2 = n2.iso_3166_1_a2)
+ LEFT JOIN geoloc_countries AS n3 ON (u.nationalite3 = n3.iso_3166_1_a2)
+ LEFT JOIN profile_addresses AS adr ON (u.user_id = adr.pid
+ AND FIND_IN_SET('current', adr.flags))
+ LEFT JOIN geoloc_countries AS gp ON (adr.countryId = gp.iso_3166_1_a2)
+ LEFT JOIN geoloc_administrativeareas AS gr ON (adr.countryId = gr.country
+ AND adr.administrativeAreaId = gr.id)
+ LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')
LEFT JOIN profile_networking AS nw ON (nw.uid = u.user_id)
- LEFT JOIN profile_networking_enum AS nwe ON (nwe.network_type = nw.network_type)';
+ LEFT JOIN profile_networking_enum AS nwe ON (nwe.network_type = nw.network_type)";
// }}}
// {{{ class ThrowError
require_once dirname(__FILE__).'/classes.inc.php';
// {{{ function advancedSearchFromInput
-function getadr_join($table) {
- return 'u.user_id = ' . $table . '.uid' . (Env::v('only_current', false) ? ' AND FIND_IN_SET(\'active\', ' . $table . '.statut)' : '');
+function getAddressJoin($table) {
+ return 'u.user_id = ' . $table . '.pid' . (Env::v('only_current', false) ? ' AND FIND_IN_SET(\'current\', ' . $table . '.flags)' : '');
}
function advancedSearchFromInput()
{
$referentField = null;
}
- if (!Env::i('cityid')) {
- $townField = new RefSField('city', array('ac.city', 'ac.postcode'), 'adresses', 'ac', getadr_join('ac'), false);
- } else {
- $townField = new RefSField('cityid', array('av.cityid', 'av.postcode'), '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('sgcim.map_id'), array('adresses', 'geoloc_city_in_maps'),
- array('amp', 'sgcim'), array(getadr_join('amp'), 'amp.cityid = sgcim.city_id'));
+ $townField = new RefSField('city', array('av.localityId', 'av.postalCode'), 'profile_addresses',
+ 'av', getAddressJoin('av'));
+ $countryField = new RefSField('country', array('ap.countryId'), 'profile_addresses', 'ap', getAddressJoin('ap'));
+ $regionField = new RefSField('region',array('ar.administrativeAreaId'), 'profile_addresses', 'ar', getAddressJoin('ar'));
$entrepriseField = new RefSField('entreprise', array('je.name'), '', '','');
$posteField = new RefSField('poste', array('ep.description'), 'profile_job', 'ep', 'u.user_id = ep.uid', false);
return array(
$nameField, $promo1Field,
$promo2Field, $womanField, $subscriberField, $aliveField,
- $townField, $countryField, $regionField, $mapField, $entrepriseField,
+ $townField, $countryField, $regionField, $entrepriseField,
$posteField, $secteurField, $cvField, $natField, $binetField,
$groupexField, $sectionField, $schoolField, $diplomaField,
$freeField, $fonctionField, $nwAddressField, $nwTypeField,
function smarty_function_display_address($param, &$smarty)
{
require_once('geoloc.inc.php');
- $txtad = get_address_text($param['adr']);
+ $txtad = $param['adr']['text'];
if (!$txtad && !$param['adr']['tels'] && !count($param['adr']['tels'])) {
return "";
}
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2009 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 *
- ***************************************************************************/
-
-function smarty_function_geoloc_country($params, &$smarty) {
- require_once 'geoloc.inc.php';
- if(!isset($params['country'])) {
- return;
- }
- return geoloc_country($params['country'], @$params['available']);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2009 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 *
- ***************************************************************************/
-
-function smarty_function_geoloc_region($params, &$smarty) {
- require_once 'geoloc.inc.php';
- if(!isset($params['country']) || !isset($params['region'])) {
- return;
- }
- return geoloc_region($params['country'], $params['region'], @$params['available']);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
function select_nat($valeur, $pad=false) {
- $sql = "SELECT a2 AS id, IF(nat='', pays, nat) AS text FROM geoloc_pays WHERE nat IS NOT NULL ORDER BY text";
- $res = XDB::iterRow($sql);
+ $res = XDB::iterRow("SELECT iso_3166_1_a2 AS id, nationalityFR AS text
+ FROM geoloc_countries
+ WHERE nationalityFR IS NOT NULL
+ ORDER BY nationalityFR");
$sel = ' selected="selected"';
// on ajoute une entree vide si $pad est vrai
</td>
</tr>
<tr class="impair">
- <td class="titre">Géoloc</td>
- <td>
- <a href="admin/geoloc">Synchro</a>
- |
- <a href="admin/geoloc/dynamap">Dynamap</a>
- </td>
- </tr>
- <tr class="pair">
<td class="titre">Compte</td>
<td>
<a href="admin/skins">Skins</a>
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2009 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>Geoloc</h1>
-
-<h2>Synchroniser des villes avec geoloc.org</h2>
-
-{if $nb_missinglat}
-<p>[<a href='admin/geoloc/missinglat'>toutes les villes sans coordonnées ({$nb_missinglat})</a>]</p>
-{/if}
-
-<form action='admin/geoloc' method='post'>
-<p>
-La ville dont l'id est : <input size="6" name="id" />
-</p>
-</form>
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2009 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='admin/geoloc/dynamaps/newmaps' 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'/>
- </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='admin/geoloc/dynamap/cities_not_on_map'>Réparer</a>]
- </p>
-{else}
- <p> Toutes les villes de la base sont placées dans des cartes. </p>
-{/if}
-{if $no_smallest}
- <p>
- Il faut <a href='admin/geoloc/dynamap/smallest_maps'>définir la plus petite carte</a>
- pour chaque ville (à ne faire qu'une fois quand on a placé toutes les villes).
- </p>
-{/if}
-{if $no_coordinates}
-<h2>
- Placement précis des adresses
-</h2>
-<p>
- {$no_coordinates} adresses n'ont pas été bien reconnues précisément.
- [<a href='admin/geoloc/dynamap/precise_coordinates'>Mettre les coordonnées du centre de la ville</a>]
-</p>
-{/if}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}\r
-{* *}\r
-{* Copyright (C) 2003-2009 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
- {foreach from=$users item="user"}{if !$beginning}<br/>{/if}{if $nb_displayed < 10}<a href="javascript:ficheXorg('{$user.alias}');">{$user.prenom} {$user.nom|strtolower|ucwords} - {$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}{/foreach}\r
-</city>\r
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}\r
+++ /dev/null
-{**************************************************************************}\r
-{* *}\r
-{* Copyright (C) 2003-2009 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}">\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}" green="{if $country.nbPop}{$country.yellow/$country.nbPop}{else}0{/if}" blue="0" alpha="0.7"/>\r
- <moreinfos url="country{$plset_search|escape_html}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}" green="{if $city.pop}{$city.yellow/$city.pop}{else}0{/if}" blue="0"/>\r
- <moreinfos url="city{$plset_search|escape_html}cityid={$city.id}"/>\r
- </city>\r
- {/foreach}\r
- </cities>\r
-</country>\r
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}\r
{* *}
{**************************************************************************}
-<input type="hidden" name="{$name}[changed]" value="0"/>
-{if $adr.geoloc}
-<div class="erreur" id="{$id}_geoloc_error">
+{if $address.geoloc}
+<div class="erreur {$prefid}_geoloc">
La geolocalisation n'a pas donné un résultat certain, valide la nouvelle adresse
ou modifie l'ancienne pour que ton adresse puisse être prise en compte.
</div>
-<script type="text/javascript">setTimeout("document.location += '#{$adid}'", 10);</script>
{/if}
+
<div>
-<textarea name="{$name}[text]" cols="30" rows="4"
- onchange="form['{$name}[changed]'].value=1"
- {if !$adr.cityid && $adr.datemaj}class="error"{/if}
- >{$adr.text}</textarea>
-{if $adr.geoloc}
-<span id="{$id}_geoloc">
-<textarea cols="30" rows="4"
- class="valid"
- name="{$name}[geoloc]"
- onclick="blur()"
- >{$adr.geoloc}</textarea>
-<input type="hidden" name="{$name}[geoloc_cityid]" value="{$adr.geoloc_cityid}" />
-<input type="hidden" name="{$name}[parsevalid]" value="0" />
-</span>
+ <textarea name="{$prefname}[text]" cols="30" rows="4" onkeyup="addressChanged({$id})"
+ {if $address.geoloc}class="error"{/if}>{$address.text}</textarea>
+{if $address.geoloc}
+ <textarea cols="30" rows="4" class="valid {$prefid}_geoloc"
+ name="{$prefname}[geoloc]">{$address.geoloc}</textarea>
</div>
-<div class="center" id="{$id}_geoloc_valid">
- <a href="javascript:validAddress('{$id}', '{$name}')">Valider ta version</a>
+<div class="center {$prefid}_geoloc">
+ <a href="javascript:validGeoloc('{$id}', 0)">Valider ta version</a>
•
- <a href="javascript:validGeoloc('{$id}', '{$name}')">Valider la version géolocalisée</a>
+ <a href="javascript:validGeoloc('{$id}', 1)">Valider la version géolocalisée</a>
{/if}
</div>
-<input type="hidden" name="{$name}[cityid]" value="{$adr.cityid}" />
-<input type="hidden" name="{$name}[adr1]" value="{$adr.adr1}" />
-<input type="hidden" name="{$name}[adr2]" value="{$adr.adr2}" />
-<input type="hidden" name="{$name}[adr3]" value="{$adr.adr3}" />
-<input type="hidden" name="{$name}[postcode]" value="{$adr.postcode}"/>
-<input type="hidden" name="{$name}[city]" value="{$adr.city}" />
-<input type="hidden" name="{$name}[country]" value="{$adr.country|default:'00'}" />
-<input type="hidden" name="{$name}[countrytxt]" value="{$adr.countrytxt}" />
-<input type="hidden" name="{$name}[region]" value="{$adr.region}" />
-<input type="hidden" name="{$name}[regiontxt]" value="{$adr.regiontxt}" />
-<input type="hidden" name="{$name}[checked]" value="{$adr.checked}" />
-<input type="hidden" name="{$name}[precise_lat]" value="{$adr.precise_lat}" />
-<input type="hidden" name="{$name}[precise_lon]" value="{$adr.precise_lon}" />
+{if $address.geoloc}
+<input type="hidden" name="{$prefname}[geoloc_choice]" value="1" />
+<input type="hidden" name="{$prefname}[geoloc]" value="{$address.geoloc}" />
+<input type="hidden" name="{$prefname}[geocodedPostalText]" value="{$address.geocodedPostalText}" />
+<input type="hidden" name="{$prefname}[updateTime]" value="{$address.updateTime}" />
+{/if}
+<input type="hidden" name="{$prefname}[type]" value="{$address.type}" />
+<input type="hidden" name="{$prefname}[accuracy]" value="{$address.accuracy}" />
+<input type="hidden" name="{$prefname}[postalAddress]" value="{$address.postalAddress}" />
+<input type="hidden" name="{$prefname}[line1]" value="{$address.line1}" />
+<input type="hidden" name="{$prefname}[line2]" value="{$address.line2}" />
+<input type="hidden" name="{$prefname}[line3]" value="{$address.line3}" />
+<input type="hidden" name="{$prefname}[postalCode]" value="{$address.postalCode}" />
+<input type="hidden" name="{$prefname}[administrativeAreaId]" value="{$address.administrativeAreaId}" />
+<input type="hidden" name="{$prefname}[subAdministrativeAreaId]" value="{$address.subAdministrativeAreaId}" />
+<input type="hidden" name="{$prefname}[locality]" value="{$address.locality}" />
+<input type="hidden" name="{$prefname}[administrativeArea]" value="{$address.administrativeArea}" />
+<input type="hidden" name="{$prefname}[subAdministrativeArea]" value="{$address.subAdministrativeArea}" />
+<input type="hidden" name="{$prefname}[localityId]" value="{$address.localityId}" />
+<input type="hidden" name="{$prefname}[countryId]" value="{$address.countryId}" />
+<input type="hidden" name="{$prefname}[latitude]" value="{$address.latitude}" />
+<input type="hidden" name="{$prefname}[longitude]" value="{$address.longitude}" />
+<input type="hidden" name="{$prefname}[north]" value="{$address.north}" />
+<input type="hidden" name="{$prefname}[south]" value="{$address.south}" />
+<input type="hidden" name="{$prefname}[east]" value="{$address.east}" />
+<input type="hidden" name="{$prefname}[west]" value="{$address.west}" />
+<input type="hidden" name="{$prefname}[cedex]" value="{$address.cedex}" />
+<input type="hidden" name="{$prefname}[updateTime]" value="{$address.updateTime}" />
+<input type="hidden" name="{$prefname}[changed]" value="0" />
+<input type="hidden" name="{$prefname}[removed]" value="0" />
+
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2009 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
-grandOncleVisibility="-1"
-tooltipSize="0"
-tooltipDX="0"
-tooltipDY="20"
-panelSize="28"
-citySize="6"
-radius100="1.6"
-radius0="3"
-select="aim"
-aimTween="5"
-transition="2"
-textLookInCity="Rechercher les x dans cette ville"
-textZoomIn="Zoom"
-textGoTo="Va à "
-textZoomBackTo="Revient à "
-textLoading="Chargement"
-textYouAreIn="Tu es dans "
-textSeeMapOfCity="Voir la carte de "
-textYouHaveSelected="Tu as sélectionné "
-{if $background}
-background="{$background}"
-zoomBarBackgroundColor="{$background}"
-{/if}
-textCopyright="Les règles de l'annuaire s'appliquent aussi à cette application"
-autofolder="true"
-iconSwf="icon.swf"
-scriptInfosArea="country{$plset_search|escape_html}">
-<translation>
- <text name="Hide/Show labels" value="Montrer/Cacher les étiquettes"/>
- <text name="- You are in " value="Vous êtes dans "/>
- <text name="Loading first part of XML data" value="Chargement des données"/>
- <text name="Loading own map" value="Chargement de la carte principale"/>
- <text name="Loading XML data" value="Chargement des données"/>
- <text name="Loading maps of sub-countries" value="Chargement des cartes"/>
-</translation>
-</config>
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2009 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 *}
-{* *}
-{**************************************************************************}
-
-<script type="text/javascript">//<![CDATA[
-{literal}
-function ficheXorg(id)
-{
- window.open('{/literal}{if !$annu}https://{#globals.core.secure_domain#}/{/if}{literal}profile/'+id,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=840,height=600');
-}
-{/literal}
-{if $annu}
-var search_url = platal_baseurl + "{$platal->ns}{$annu}{$plset_search|smarty:nodefaults}";
-{literal}
-function clickOnCity(id)
-{
- window.open(search_url + unescape('%26')+'cityid=' + id, '_blank', '');
-}
-var mapid = 0;
-function goToCountry(id)
-{
- mapid = id;
-}
-function searchMapId()
-{
- window.open(search_url + unescape('%26')+'mapid=' + mapid, '_blank', '');
-}
-{/literal}
-{/if}
-
-//]]></script>
-
-{if !$request_geodesix}
-
- <p class="center">
- {if $smarty.request.only_current neq 'on'}
- [<a href="{$platal->ns}{$plset_base}/geoloc{$plset_search}only_current=on">Ne voir que les adresses principales</a>]
- {else}
- [<a href="{$platal->ns}{$plset_base}/geoloc{$plset_search|replace:'only_current=on':''}">Voir toutes les adresses</a>]
- {/if}
- </p>
-
- <p class="center">
- <object
- type="application/x-shockwave-flash"
- data="{$platal->ns}{$plset_base}/geoloc/dynamap.swf"
- width="600"
- height="450">
- <param name="movie" value="{$platal->ns}{$plset_base}/geoloc/dynamap.swf"/>
- <param name="wmode" value="transparent"/>
- <param name="flashvars" value="initfile=init{$plset_search_enc}"/>
- </object>
- </p>
- {if $annu}
- <p class="center">
- <a href="javascript:searchMapId()">Lister les X présents sur cette carte</a>
- </p>
- {/if}
- <p class="smaller">Carte fournie gracieusement par <a href="http://www.geodesix.com/">Geodesix</a>.</p>
-{else}
- <p>Le moteur de carte n'a pas été installé sur cette version de plat/al. Veuillez contacter <a href="http://www.geodesix.com/">Geodesix</a>.</p>
-{/if}
-<p class="descr">Pour toute question, problème ou suggestion tu peux envoyer un email à
-<a href="mailto:{#globals.geoloc.email#}">{#globals.geoloc.email#}</a>.</p>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-{assign var=adpref value="addresses[$i]"}
-{assign var=adid value="addresses_$i"}
-<input type="hidden" name="{$adpref}[removed]" value="0"/>
-<input type="hidden" name="{$adpref}[datemaj]" value="{$adr.datemaj}"/>
-<table class="bicol" style="display: none; margin-bottom: 1em" id="{$adid}_grayed">
+{assign var=prefname value="addresses[$i]"}
+{assign var=prefid value="addresses_$i"}
+<table class="bicol" style="display: none; margin-bottom: 1em" id="{$prefid}_grayed">
<tr>
<th class="grayed">
<div style="float: right">
- <a href="javascript:restoreAddress('{$adid}', '{$adpref}')">{icon name=arrow_refresh title="Restaurer l'adresse"}</a>
+ <a href="javascript:toggleAddress('{$i}', 0)">{icon name=arrow_refresh title="Restaurer l'adresse"}</a>
</div>
Restaurer l'adresse n°{$i+1}
</th>
</tr>
</table>
-<table class="bicol" style="margin-bottom: 1em" id="{$adid}">
+<table class="bicol" style="margin-bottom: 1em" id="{$prefid}">
<tr>
<th>
<div style="float: left">
- <input name="{$adpref}[current]" type="radio" value="1" {if $adr.current}checked="checked"{/if}
- id="{$adid}_current" onchange="checkCurrentAddress(this); return true" />
- <label for="{$adid}_current" class="smaller" style="font-weight: normal">actuelle</label>
+ <label>
+ <input name="{$prefname}[current]" type="radio" {if $address.current}checked="checked"{/if}
+ onchange="checkCurrentAddress({$i})" />
+ <span class="smaller" style="font-weight: normal">actuelle</span>
+ </label>
</div>
<div style="float: right">
- <a href="javascript:removeAddress('{$adid}', '{$adpref}')">{icon name=cross title="Supprimer l'adresse"}</a>
+ <a href="javascript:toggleAddress('{$i}', 1)">
+ {icon name=cross title="Supprimer l'adresse"}
+ </a>
</div>
Adresse n°{$i+1}
</th>
<tr>
<td>
<div style="margin-bottom: 0.2em" class="flags">
- {include file="include/flags.radio.tpl" name="`$adpref`[pub]" val=$adr.pub}
+ {include file="include/flags.radio.tpl" name="`$prefname`[pub]" val=$address.pub}
</div>
<div style="clear: both"></div>
- <div style="float: left">{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}</div>
+ <div style="float: left">
+ {include file="geoloc/form.address.tpl" prefname=$prefname prefid=$prefid address=$address id=$i}
+ </div>
<div style="float: left">
<div>
- <input type="radio" name="{$adpref}[temporary]" id="{$adid}_temp_0" value="0"
- {if !$adr.temporary}checked="checked"{/if} /><label for="{$adid}_temp_0">permanente</label>
- <input type="radio" name="{$adpref}[temporary]" id="{$adid}_temp_1" value="1"
- {if $adr.temporary}checked="checked"{/if} /><label for="{$adid}_temp_1">temporaire</label>
+ <label>
+ <input type="radio" name="{$prefname}[temporary]" value="0"
+ {if !$address.temporary}checked="checked"{/if} />
+ permanente
+ </label>
+ <label>
+ <input type="radio" name="{$prefname}[temporary]" value="1"
+ {if $address.temporary}checked="checked"{/if} />
+ temporaire
+ </label>
</div>
<div>
- <input type="radio" name="{$adpref}[secondaire]" id="{$adid}_sec_0" value="0"
- {if !$adr.secondaire}checked="checked"{/if} /><label for="{$adid}_sec_0">ma résidence principale</label>
- <input type="radio" name="{$adpref}[secondaire]" id="{$adid}_sec_1" value="1"
- {if $adr.secondaire}checked="checked"{/if} /><label for="{$adid}_sec_1">une résidence secondaire</label>
+ <label>
+ <input type="radio" name="{$prefname}[secondary]" value="0"
+ {if !$address.secondary}checked="checked"{/if} />
+ ma résidence principale
+ </label>
+ <label>
+ <input type="radio" name="{$prefname}[secondary]" value="1"
+ {if $address.secondary}checked="checked"{/if} />
+ une résidence secondaire
+ </label>
</div>
<div>
- <input type="checkbox" name="{$adpref}[mail]" id="{$adid}_mail"
- {if $adr.mail}checked="checked"{/if} />
- <label for="{$adid}_mail">on peut m'y envoyer du courrier par la poste</label>
+ <label>
+ <input type="checkbox" name="{$prefname}[mail]" {if $address.mail}checked="checked"{/if} />
+ on peut m'y envoyer du courrier par la poste
+ </label>
</div>
<div>
- <label for="{$adpref}[comment]">Commentaire : </label>
- <input type="text" size="35" maxlength="100" name="{$adpref}[comment]" id="{$adpref}_comment" value="{$adr.comment}" />
+ <label>
+ Commentaire :
+ <input type="text" size="35" maxlength="100"
+ name="{$prefname}[comment]" value="{$address.comment}" />
+ </label>
</div>
</div>
</td>
</tr>
<tr class="pair">
<td>
- {foreach from=$adr.tel key=t item=tel}
- <div id="{"`$adid`_tel_`$t`"}" style="clear: both">
- {include file="profile/phone.tpl" prefname="`$adpref`[tel]" prefid="`$adid`_tel" telid=$t tel=$tel}
+ {foreach from=$address.tel key=t item=tel}
+ <div id="{"`$prefid`_tel_`$t`"}" style="clear: both">
+ {include file="profile/phone.tpl" prefname="`$prefname`[tel]"
+ prefid="`$prefid`_tel" telid=$t tel=$tel}
</div>
{/foreach}
- {if $adr.tel|@count eq 0}
- <div id="{"`$adid`_tel_0"}" style="clear: both">
- {include file="profile/phone.tpl" prefname="`$adpref`[tel]" prefid="`$adid`_tel" telid=0 tel=0}
+ {if $address.tel|@count eq 0}
+ <div id="{"`$prefid`_tel_0"}" style="clear: both">
+ {include file="profile/phone.tpl" prefname="`$prefname`[tel]" prefid="`$prefid`_tel" telid=0 tel=0}
</div>
{/if}
- <div id="{$adid}_tel_add" class="center" style="clear: both; padding-top: 4px">
- <a href="javascript:addTel('{$adid}_tel', '{$adpref}[tel]')">
+ <div id="{$prefid}_tel_add" class="center" style="clear: both; padding-top: 4px">
+ <a href="javascript:addTel('{$prefid}_tel', '{$prefname}[tel]')">
{icon name=add title="Ajouter un numéro de téléphone"} Ajouter un numéro de téléphone
</a>
</div>
{* *}
{**************************************************************************}
-{foreach key=i item=adr from=$addresses}
+{foreach key=i item=address from=$addresses}
<div id="{"addresses_`$i`_cont"}">
-{include file="profile/adresses.address.tpl" i=$i adr=$adr}
+{include file="profile/adresses.address.tpl" i=$i address=$address}
</div>
{/foreach}
{if $addresses|@count eq 0}
<div id="addresses_0_cont">
-{include file="profile/adresses.address.tpl" i=0 adr=0}
+{include file="profile/adresses.address.tpl" i=0 address=0}
</div>
{/if}
-<div id="add_adr" class="center">
+<div id="add_address" class="center">
<a href="javascript:addAddress()">
{icon name=add title="Ajouter une adresse"} Ajouter une adresse
</a>
<ul style="padding-top:0px;padding-bottom:0px">
<li><a href="http://www.polytechnique.net/{$asso->diminutif}/annuaire">annuaire</a></li>
<li><a href="http://www.polytechnique.net/{$asso->diminutif}/trombi">trombino</a></li>
- <li><a href="http://www.polytechnique.net/{$asso->diminutif}/geoloc">carte</a></li>
{if $asso->lists}
<li><a href="http://www.polytechnique.net/{$asso->diminutif}/lists">listes de diffusion</a></li>
{/if}
<a href="javascript:addCountry()">{icon name=add title="Ajouter ce pays"}</a>
</div>
<select name="countries_sel" onchange="updateCountry()">
- {geoloc_country country='00'}
+ <option value=""></option>
+ {iterate from=$countryList item=country}
+ <option value="{$country.iso_3166_1_a2}">{$country.countryFR}</option>
+ {/iterate}
</select>
</td>
</tr>
<div class="menu_title">Communauté X</div>
<div class="menu_item"><a href="search">Annuaire</a></div>
-<div class="menu_item"><a href="geoloc">Planisphère</a></div>
<div class="menu_item"><a href="emploi">Emploi & Carrières</a></div>
<div class="menu_item"><a href="groupes-x">Mes groupes X</a></div>
<div class="menu_item"><a href="survey">Sondages</a></div>
<ul>
{foreach from=$not_in_group_x item=n}
- <li>{$n} [<a href='{$platal->ns}member/new/{$n}' class='popup'>l'inscrire</a>]</li>
+ <li>{$n} [<a href='{$platal->ns}member/new/{$n}?token={xsrf_token}' class='popup'>l'inscrire</a>]</li>
{foreachelse}
<li><em>tous les polytechniciens présents sur les listes sont inscrits à l'annuaire du groupe.</em></li>
{/foreach}
<h2>Non polytechniciens</h2>
<ul>
{foreach from=$not_in_group_ext item=n}
- <li>{$n} [<a href='{$platal->ns}member/new/{$n}' class='popup'>l'inscrire</a>]</li>
+ <li>{$n} [<a href='{$platal->ns}member/new/{$n}?token={xsrf_token}' class='popup'>l'inscrire</a>]</li>
{foreachelse}
<li><em>tous les non-polytechniciens présents sur les listes sont inscrits à l'annuaire du groupe.</em></li>
{/foreach}
--- /dev/null
+CREATE TABLE IF NOT EXISTS profile_addresses (
+ pid INT(11) DEFAULT NULL,
+ jobid INT(6) UNSIGNED DEFAULT NULL,
+ type ENUM('home','job','hq') NOT NULL DEFAULT 'home',
+ id TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+ flags SET('current','temporary','secondary','mail','cedex') DEFAULT NULL,
+ accuracy TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+ text TEXT NOT NULL,
+ postalText TEXT NOT NULL,
+ postalCode VARCHAR(255) DEFAULT NULL,
+ localityId INT(11) DEFAULT NULL,
+ subAdministrativeAreaId INT(11) DEFAULT NULL,
+ administrativeAreaId INT(11) DEFAULT NULL,
+ countryId CHAR(2) DEFAULT NULL,
+ latitude FLOAT(10,7) DEFAULT NULL,
+ longitude FLOAT(10,7) DEFAULT NULL,
+ north FLOAT(10,7) DEFAULT NULL,
+ south FLOAT(10,7) DEFAULT NULL,
+ east FLOAT(10,7) DEFAULT NULL,
+ west FLOAT(10,7) DEFAULT NULL,
+ updateTime DATE NOT NULL DEFAULT 0,
+ pub ENUM('public','ax','private') NOT NULL DEFAULT 'private',
+ comment VARCHAR(255) DEFAULT NULL,
+ PRIMARY KEY(pid, jobid, type, id),
+ INDEX pid (pid),
+ INDEX jobid (jobid),
+ INDEX type (type),
+ INDEX adrid (id),
+ INDEX localityId (localityId),
+ INDEX administrativeAreaId (administrativeAreaId),
+ INDEX subAdministrativeAreaId (subAdministrativeAreaId),
+ INDEX countryId (countryId)
+) CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS geoloc_countries (
+ iso_3166_1_a2 CHAR(2) NOT NULL,
+ iso_3166_1_a3 CHAR(3) NOT NULL,
+ iso_3166_1_num SMALLINT(3) UNSIGNED NOT NULL,
+ worldRegion CHAR(2) DEFAULT NULL,
+ countryFR VARCHAR(255) NOT NULL,
+ country VARCHAR(255) NOT NULL,
+ capital VARCHAR(255) NOT NULL,
+ nationalityFR VARCHAR(255) DEFAULT NULL,
+ nationality VARCHAR(255) DEFAULT NULL,
+ phonePrefix SMALLINT(5) UNSIGNED DEFAULT NULL,
+ phoneFormat VARCHAR(255) NOT NULL,
+ licensePlate CHAR(4) DEFAULT NULL,
+ belongsTo CHAR(2) DEFAULT NULL,
+ PRIMARY KEY(iso_3166_1_a2),
+ UNIQUE KEY(iso_3166_1_a3),
+ UNIQUE KEY(iso_3166_1_num),
+ INDEX(iso_3166_1_a2),
+ INDEX(phonePrefix)
+) CHARSET=utf8;
+
+UPDATE geoloc_pays
+ SET n3 = 450
+ WHERE a2 = "MG";
+
+UPDATE geoloc_pays
+ SET n3 = 807
+ WHERE a2 = "MK";
+
+INSERT INTO geoloc_countries (iso_3166_1_a2, iso_3166_1_a3, iso_3166_1_num, worldRegion,
+ countryFR, country, capital, nationalityFR,
+ phonePrefix, phoneFormat, licensePlate)
+ SELECT a2, a3, n3, worldrgn, pays, country, capital, nat, phoneprf, phoneformat, license_plate
+ FROM geoloc_pays;
+
+CREATE TABLE IF NOT EXISTS geoloc_administrativeareas (
+ id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ name VARCHAR(255) NOT NULL,
+ country CHAR(2) NOT NULL,
+ PRIMARY KEY(id),
+ UNIQUE KEY(id, name, country),
+ INDEX(id),
+ INDEX(name),
+ INDEX(country)
+) CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS geoloc_subadministrativeareas (
+ id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ name VARCHAR(255) NOT NULL,
+ country CHAR(2) NOT NULL,
+ PRIMARY KEY(id),
+ UNIQUE KEY(id, name, country),
+ INDEX(id),
+ INDEX(name),
+ INDEX(country)
+) CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS geoloc_localities (
+ id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+ name VARCHAR(255) NOT NULL,
+ country CHAR(2) NOT NULL,
+ PRIMARY KEY(id),
+ UNIQUE KEY(id, name, country),
+ INDEX(id),
+ INDEX(name),
+ INDEX(country)
+) CHARSET=utf8;
+
+-- vim:set syntax=mysql:
--- /dev/null
+ALTER TABLE geoloc_countries MODIFY COLUMN phoneFormat VARCHAR(255) NOT NULL DEFAULT "";
+
+DELETE FROM geoloc_countries
+ WHERE iso_3166_1_a2 = "TP" OR iso_3166_1_a2 = "YU";
+
+INSERT INTO geoloc_countries (iso_3166_1_a2, iso_3166_1_a3, iso_3166_1_num, worldRegion,
+ country, countryFR, capital, nationalityFR,
+ licensePlate, belongsTo, phonePrefix)
+ VALUES ("AX", "ALA", 248, "EU", "Åland, Îles", "Åland Islands", "Mariehamn", NULL, "AX", "FI", 358),
+ ("GG", "GGY", 831, "EU", "Guernsey", "Guernesey", "St Peter Port", NULL, "GBG", "GB", 44),
+ ("GY", "GUY", 328, NULL, "Guyana", "Guyana", "Georgetown", "Guyanien", "GUY", NULL, 592),
+ ("HK", "HKG", 344, NULL, "Hong Kong", "Hong-Kong", "Hong-Kong", "Hongkongais", "HK", NULL, 852),
+ ("IM", "IMN", 833, NULL, "Isle of Man", "Île de Man", "Douglas", "Mannois", "GBM", NULL, 44),
+ ("JE", "JEY", 832, NULL, "Jersey", "Jersey", "Saint-Hélier", "Jersiais", "GBJ", NULL, 44),
+ ("MO", "MAC", 446, NULL, "Macao", "Macao", "Macao", "Macanais", "MO", NULL, 853),
+ ("ME", "MNE", 499, NULL, "Montenegro", "Monténégro", "Podgorica", "Monténégrin", "MNE",
+ NULL, 382),
+ ("PS", "PSE", 275, NULL, "Palestinian Territory, Occupied", "Palestiniens occupé, Territoire",
+ "Jérusalem", "Palestinien", "PS", NULL, 970),
+ ("BL", "BLM", 652, "EU", "Saint Barthélemy", "Saint-Barthélemy", "Gustavia", NULL, "F", "FR", 33),
+ ("MF", "MAF", 663, "EU", "Saint Martin", "Saint-Martin", "Marigot", NULL, "F", "FR", 33),
+ ("PM", "SPM", 666, "EU", "Saint Pierre and Miquelon", "Saint-Pierre-et-Miquelon", "Saint-Pierre",
+ NULL, "F", "FR", 33),
+ ("RS", "SRB", 688, NULL, "Serbia", "Serbie", "Belgrade", "Serbe", "SRB", NULL, 381),
+ ("TL", "TLS", 626, NULL, "Timor-Leste", "Timor-Leste", "Dili", "Timorais", "TL", NULL, 670);
+
+UPDATE geoloc_countries
+ SET country = "Croatia"
+ WHERE iso_3166_1_a2 = "HR";
+
+UPDATE geoloc_countries
+ SET country = "Slovakia"
+ WHERE iso_3166_1_a2 = "SK";
+
+UPDATE geoloc_countries
+ SET country = "Saint Helena"
+ WHERE iso_3166_1_a2 = "SH";
+
+UPDATE geoloc_countries
+ SET countryFR = "Antigua-et-Barbuda"
+ WHERE iso_3166_1_a2 = "AG";
+
+UPDATE geoloc_countries
+ SET countryFR = "Cameroun"
+ WHERE iso_3166_1_a2 = "CM";
+
+UPDATE geoloc_countries
+ SET countryFR = "Centrafricaine, République"
+ WHERE iso_3166_1_a2 = "CF";
+
+UPDATE geoloc_countries
+ SET countryFR = "Cocos (Keeling), Îles"
+ WHERE iso_3166_1_a2 = "CC";
+
+UPDATE geoloc_countries
+ SET countryFR = "Égypte"
+ WHERE iso_3166_1_a2 = "EG";
+
+UPDATE geoloc_countries
+ SET countryFR = "Émirats arabes unis"
+ WHERE iso_3166_1_a2 = "AE";
+
+UPDATE geoloc_countries
+ SET countryFR = "Équateur"
+ WHERE iso_3166_1_a2 = "EC";
+
+UPDATE geoloc_countries
+ SET countryFR = "Érythrée"
+ WHERE iso_3166_1_a2 = "ER";
+
+UPDATE geoloc_countries
+ SET countryFR = "Èthiopie"
+ WHERE iso_3166_1_a2 = "ET";
+
+UPDATE geoloc_countries
+ SET countryFR = "États-Unis"
+ WHERE iso_3166_1_a2 = "US";
+
+UPDATE geoloc_countries
+ SET countryFR = "Géorgie du Sud et les Îles Sandwich du Sud"
+ WHERE iso_3166_1_a2 = "GS";
+
+UPDATE geoloc_countries
+ SET countryFR = "Guinée-Bissau"
+ WHERE iso_3166_1_a2 = "GW";
+
+UPDATE geoloc_countries
+ SET countryFR = "Heard, Île et MacDonald"
+ WHERE iso_3166_1_a2 = "HM";
+
+UPDATE geoloc_countries
+ SET countryFR = "Îles mineures éloignées des États-Unis"
+ WHERE iso_3166_1_a2 = "UM";
+
+UPDATE geoloc_countries
+ SET countryFR = "Îles vierges britanniques", country = "Virgin Islands, British"
+ WHERE iso_3166_1_a2 = "VG";
+
+UPDATE geoloc_countries
+ SET countryFR = "Îles vierges des États-Unis", country = "Virgin Islands, US"
+ WHERE iso_3166_1_a2 = "VI";
+
+UPDATE geoloc_countries
+ SET countryFR = "Iran, République islamique d'"
+ WHERE iso_3166_1_a2 = "IR";
+
+UPDATE geoloc_countries
+ SET countryFR = "Lao, République démocratique populaire"
+ WHERE iso_3166_1_a2 = "LA";
+
+UPDATE geoloc_countries
+ SET countryFR = "Macédoine, L'Ex-République Yougoslave"
+ WHERE iso_3166_1_a2 = "MK";
+
+UPDATE geoloc_countries
+ SET countryFR = "Micronésie, États fédérés de"
+ WHERE iso_3166_1_a2 = "FM";
+
+UPDATE geoloc_countries
+ SET countryFR = "Océan Indien, Territoire britannique de l'"
+ WHERE iso_3166_1_a2 = "IO";
+
+UPDATE geoloc_countries
+ SET countryFR = "Russie, Fédération de"
+ WHERE iso_3166_1_a2 = "RU";
+
+UPDATE geoloc_countries
+ SET countryFR = "Saint-Siège (État de la Cité du Vatican)"
+ WHERE iso_3166_1_a2 = "VA";
+
+UPDATE geoloc_countries
+ SET countryFR = "Saint-Kitts-et-Nevis"
+ WHERE iso_3166_1_a2 = "KN";
+
+UPDATE geoloc_countries
+ SET countryFR = "Congo, La République démocratique du"
+ WHERE iso_3166_1_a2 = "CD";
+
+UPDATE geoloc_countries
+ SET countryFR = "Saint-Vincent-et-les-Grenadines"
+ WHERE iso_3166_1_a2 = "VC";
+
+UPDATE geoloc_countries
+ SET countryFR = "Samoa"
+ WHERE iso_3166_1_a2 = "WS";
+
+UPDATE geoloc_countries
+ SET countryFR = "Sao Tomé-et-Principe"
+ WHERE iso_3166_1_a2 = "ST";
+
+UPDATE geoloc_countries
+ SET countryFR = "Svalbard et Île Jan Mayen"
+ WHERE iso_3166_1_a2 = "SJ";
+
+UPDATE geoloc_countries
+ SET countryFR = "Trinité-et-Tobago"
+ WHERE iso_3166_1_a2 = "TT";
+
+UPDATE geoloc_countries
+ SET countryFR = "Venezuela"
+ WHERE iso_3166_1_a2 = "VE";
+
+UPDATE geoloc_countries
+ SET countryFR = "Viet Nam"
+ WHERE iso_3166_1_a2 = "VN";
+
+UPDATE geoloc_countries
+ SET countryFR = "Wallis et Futuna", country = "Wallis and Futuna"
+ WHERE iso_3166_1_a2 = "WF";
+
+UPDATE geoloc_countries
+ SET countryFR = "Yémen"
+ WHERE iso_3166_1_a2 = "YE";
+
+UPDATE geoloc_countries
+ SET belongsTo = "FR"
+ WHERE iso_3166_1_a2 = "GF" OR iso_3166_1_a2 = "PF" OR iso_3166_1_a2 = "TF"
+ OR iso_3166_1_a2 = "GP" OR iso_3166_1_a2 = "MQ" OR iso_3166_1_a2 = "YT"
+ OR iso_3166_1_a2 = "NC" OR iso_3166_1_a2 = "RE";
+
+UPDATE geoloc_countries
+ SET belongsTo = "US", nationalityFR = NULL
+ WHERE iso_3166_1_a2 = "UM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Afghan"
+ WHERE iso_3166_1_a2 = "AF";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Andorran"
+ WHERE iso_3166_1_a2 = "AD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "The Valley"
+ WHERE iso_3166_1_a2 = "AI";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Angolais"
+ WHERE iso_3166_1_a2 = "AO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL
+ WHERE iso_3166_1_a2 = "AQ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Antiguais"
+ WHERE iso_3166_1_a2 = "AG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "NL", capital = "Willemstad"
+ WHERE iso_3166_1_a2 = "AN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Saoudien", capital = "Riyad"
+ WHERE iso_3166_1_a2 = "SA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Arménien"
+ WHERE iso_3166_1_a2 = "AM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Arubais", capital = "Oranjestad"
+ WHERE iso_3166_1_a2 = "AW";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Azerbaïdjanais"
+ WHERE iso_3166_1_a2 = "AZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Bahaméen"
+ WHERE iso_3166_1_a2 = "BS";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Bahreïnien"
+ WHERE iso_3166_1_a2 = "BH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Bangladais"
+ WHERE iso_3166_1_a2 = "BD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Barbadien"
+ WHERE iso_3166_1_a2 = "BB";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Biélorusse", capital = "Minsk"
+ WHERE iso_3166_1_a2 = "BY";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Béliziens"
+ WHERE iso_3166_1_a2 = "BZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB"
+ WHERE iso_3166_1_a2 = "BM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Bolivien"
+ WHERE iso_3166_1_a2 = "BO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Bosnien"
+ WHERE iso_3166_1_a2 = "BA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "NO"
+ WHERE iso_3166_1_a2 = "BV";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Brunéiens"
+ WHERE iso_3166_1_a2 = "BN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Burundais"
+ WHERE iso_3166_1_a2 = "BI";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "George Town"
+ WHERE iso_3166_1_a2 = "KY";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Cap-verdiens"
+ WHERE iso_3166_1_a2 = "CV";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Centrafricain"
+ WHERE iso_3166_1_a2 = "CF";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "AU", capital = "Flying Fish Cove"
+ WHERE iso_3166_1_a2 = "CX";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Chypriotes"
+ WHERE iso_3166_1_a2 = "CY";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "AU", capital = "West Island"
+ WHERE iso_3166_1_a2 = "CC";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Comorien"
+ WHERE iso_3166_1_a2 = "KM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Congolais"
+ WHERE iso_3166_1_a2 = "CG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Nord-Coréens"
+ WHERE iso_3166_1_a2 = "CK";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Maori des îles Cook"
+ WHERE iso_3166_1_a2 = "KP";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Djibouti"
+ WHERE iso_3166_1_a2 = "DJ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Dominicain"
+ WHERE iso_3166_1_a2 = "DO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Dominiquais"
+ WHERE iso_3166_1_a2 = "DM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Salvadorien"
+ WHERE iso_3166_1_a2 = "SV";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Émirien"
+ WHERE iso_3166_1_a2 = "AE";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Érythréen"
+ WHERE iso_3166_1_a2 = "ER";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Éthiopiens"
+ WHERE iso_3166_1_a2 = "ET";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Port Stanley"
+ WHERE iso_3166_1_a2 = "FK";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "DK"
+ WHERE iso_3166_1_a2 = "FO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Fidjiens"
+ WHERE iso_3166_1_a2 = "FJ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Gambiens"
+ WHERE iso_3166_1_a2 = "GM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Grytviken"
+ WHERE iso_3166_1_a2 = "GS";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Géorgien", capital = "Tbilissi"
+ WHERE iso_3166_1_a2 = "GE";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Ghanéen"
+ WHERE iso_3166_1_a2 = "GH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB"
+ WHERE iso_3166_1_a2 = "GI";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Grenadien"
+ WHERE iso_3166_1_a2 = "GD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "DK", capital = "Nuuk"
+ WHERE iso_3166_1_a2 = "GL";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "US"
+ WHERE iso_3166_1_a2 = "GU";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Guatémaltèque"
+ WHERE iso_3166_1_a2 = "GT";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Guinéens"
+ WHERE iso_3166_1_a2 = "GN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Bissau-Guinéens"
+ WHERE iso_3166_1_a2 = "GW";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Équato-Guinéens"
+ WHERE iso_3166_1_a2 = "GQ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "FR", capital = "Cayenne"
+ WHERE iso_3166_1_a2 = "GF";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "AU"
+ WHERE iso_3166_1_a2 = "HM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Hondurien"
+ WHERE iso_3166_1_a2 = "HN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Road Town"
+ WHERE iso_3166_1_a2 = "VG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "US", capital = "Charlotte Amalie"
+ WHERE iso_3166_1_a2 = "VI";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Indonésien", capital = "Jakarta"
+ WHERE iso_3166_1_a2 = "ID";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Irakien", capital = "Bagdad"
+ WHERE iso_3166_1_a2 = "IQ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Jordanien", capital = "Amman"
+ WHERE iso_3166_1_a2 = "JO";
+
+UPDATE geoloc_countries
+ SET capital = "New Delhi"
+ WHERE iso_3166_1_a2 = "IN";
+
+UPDATE geoloc_countries
+ SET capital = "Téhéran"
+ WHERE iso_3166_1_a2 = "IR";
+
+UPDATE geoloc_countries
+ SET capital = "Jérusalem"
+ WHERE iso_3166_1_a2 = "IL";
+
+UPDATE geoloc_countries
+ SET capital = "Tōkyō"
+ WHERE iso_3166_1_a2 = "JP";
+
+UPDATE geoloc_countries
+ SET capital = "Astana"
+ WHERE iso_3166_1_a2 = "KZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Kirghiz", capital = "Bichkek"
+ WHERE iso_3166_1_a2 = "KG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Koweïtien", capital = "Koweït"
+ WHERE iso_3166_1_a2 = "KW";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Kényan"
+ WHERE iso_3166_1_a2 = "KE";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Gilbertins"
+ WHERE iso_3166_1_a2 = "KI";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Laotien", capital = "Vientiane"
+ WHERE iso_3166_1_a2 = "LA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Lesothans"
+ WHERE iso_3166_1_a2 = "LS";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Libérien"
+ WHERE iso_3166_1_a2 = "LR";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Libyen"
+ WHERE iso_3166_1_a2 = "LY";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Liechtensteinois"
+ WHERE iso_3166_1_a2 = "LI";
+
+UPDATE geoloc_countries
+ SET capital = "Beyrouth"
+ WHERE iso_3166_1_a2 = "LB";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Malaisien", capital = "Putrajaya"
+ WHERE iso_3166_1_a2 = "MY";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Malawites"
+ WHERE iso_3166_1_a2 = "MW";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Maldivien", capital = "Malé"
+ WHERE iso_3166_1_a2 = "MV";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Maltais"
+ WHERE iso_3166_1_a2 = "MT";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "US", capital = "Saipan"
+ WHERE iso_3166_1_a2 = "MP";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Marshallais"
+ WHERE iso_3166_1_a2 = "MH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Mauricien"
+ WHERE iso_3166_1_a2 = "MU";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Mauritanien"
+ WHERE iso_3166_1_a2 = "MR";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Micronésien"
+ WHERE iso_3166_1_a2 = "FM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Moldave"
+ WHERE iso_3166_1_a2 = "MD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Monégasque"
+ WHERE iso_3166_1_a2 = "MC";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Mongol", capital = "Oulan-Bator"
+ WHERE iso_3166_1_a2 = "MN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Plymouth["
+ WHERE iso_3166_1_a2 = "MS";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Mozambicain"
+ WHERE iso_3166_1_a2 = "MZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Birman", capital = "Naypyidaw"
+ WHERE iso_3166_1_a2 = "MM";
+
+UPDATE geoloc_countries
+ SET capital = "Mamoudzou"
+ WHERE iso_3166_1_a2 = "YT";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Namibien"
+ WHERE iso_3166_1_a2 = "NA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Nauruan"
+ WHERE iso_3166_1_a2 = "NR";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Népalais", capital = "Katmandou"
+ WHERE iso_3166_1_a2 = "NP";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Nicaraguayen"
+ WHERE iso_3166_1_a2 = "NI";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Nigérien"
+ WHERE iso_3166_1_a2 = "NE";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Nigérian"
+ WHERE iso_3166_1_a2 = "NG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Niuéen"
+ WHERE iso_3166_1_a2 = "NU";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "AU", capital = "Kingston"
+ WHERE iso_3166_1_a2 = "NF";
+
+UPDATE geoloc_countries
+ SET capital = "Nouméa"
+ WHERE iso_3166_1_a2 = "NC";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Diego Garcia"
+ WHERE iso_3166_1_a2 = "IO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Omani", capital = "Mascate"
+ WHERE iso_3166_1_a2 = "OM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Ougandais"
+ WHERE iso_3166_1_a2 = "UG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Ouzbek", capital = "Tachkent"
+ WHERE iso_3166_1_a2 = "UZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Qatari", capital = "Doha"
+ WHERE iso_3166_1_a2 = "QA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Pakistanais", capital = "Islamabad"
+ WHERE iso_3166_1_a2 = "PK";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Philippins", capital = "Manille"
+ WHERE iso_3166_1_a2 = "PH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Adamstown"
+ WHERE iso_3166_1_a2 = "PN";
+
+UPDATE geoloc_countries
+ SET capital = "Papeete"
+ WHERE iso_3166_1_a2 = "PF";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Palaien"
+ WHERE iso_3166_1_a2 = "PW";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Panaméen"
+ WHERE iso_3166_1_a2 = "PA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Papouasien"
+ WHERE iso_3166_1_a2 = "PG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Paraguayen"
+ WHERE iso_3166_1_a2 = "PY";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "US"
+ WHERE iso_3166_1_a2 = "PR";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Congolais"
+ WHERE iso_3166_1_a2 = "CD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Rwandais"
+ WHERE iso_3166_1_a2 = "RW";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, capital = ""
+ WHERE iso_3166_1_a2 = "EH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Vatican"
+ WHERE iso_3166_1_a2 = "VA";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Kititien"
+ WHERE iso_3166_1_a2 = "KN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Saint-marinois"
+ WHERE iso_3166_1_a2 = "SM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Saint-Vincentais, Grenadin"
+ WHERE iso_3166_1_a2 = "VC";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Jamestown"
+ WHERE iso_3166_1_a2 = "SH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Saint-Lucien"
+ WHERE iso_3166_1_a2 = "LC";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Salomonien"
+ WHERE iso_3166_1_a2 = "SB";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "US", capital = "Fagatogo"
+ WHERE iso_3166_1_a2 = "AS";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Samoan"
+ WHERE iso_3166_1_a2 = "WS";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Santoméen"
+ WHERE iso_3166_1_a2 = "ST";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Seychellois"
+ WHERE iso_3166_1_a2 = "SC";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Sierra-Léonais"
+ WHERE iso_3166_1_a2 = "SL";
+
+UPDATE geoloc_countries
+ SET capital = "Singapour"
+ WHERE iso_3166_1_a2 = "SG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Slovaques"
+ WHERE iso_3166_1_a2 = "SK";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Somalien"
+ WHERE iso_3166_1_a2 = "SO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Soudanais"
+ WHERE iso_3166_1_a2 = "SD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Sri Lankais", capital = "Sri Jayawardenapura"
+ WHERE iso_3166_1_a2 = "LK";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Surinamien"
+ WHERE iso_3166_1_a2 = "SR";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "NO"
+ WHERE iso_3166_1_a2 = "SJ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Swazi", capital = "Mbabane"
+ WHERE iso_3166_1_a2 = "SZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Syrien", capital = "Damas"
+ WHERE iso_3166_1_a2 = "SY";
+
+UPDATE geoloc_countries
+ SET capital = "Douchanbé"
+ WHERE iso_3166_1_a2 = "TJ";
+
+UPDATE geoloc_countries
+ SET capital = "Taipei"
+ WHERE iso_3166_1_a2 = "TW";
+
+UPDATE geoloc_countries
+ SET capital = "Saint-Pierre", nationalityFR = NULL, belongsTo = "FR"
+ WHERE iso_3166_1_a2 = "TF";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Thaïlandais", capital = "Bangkok"
+ WHERE iso_3166_1_a2 = "TH";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "NZ"
+ WHERE iso_3166_1_a2 = "TK";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Turkmène", capital = "Achgabat"
+ WHERE iso_3166_1_a2 = "TM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "GB", capital = "Cockburn Town"
+ WHERE iso_3166_1_a2 = "TC";
+
+UPDATE geoloc_countries
+ SET capital = "Ankara"
+ WHERE iso_3166_1_a2 = "TR";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Tanzanien"
+ WHERE iso_3166_1_a2 = "TZ";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Tchadien"
+ WHERE iso_3166_1_a2 = "TD";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Togolais"
+ WHERE iso_3166_1_a2 = "TG";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Tongien"
+ WHERE iso_3166_1_a2 = "TO";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Trinidadien"
+ WHERE iso_3166_1_a2 = "TT";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Tuvaluan"
+ WHERE iso_3166_1_a2 = "TV";
+
+UPDATE geoloc_countries
+ SET capital = "Hanoi"
+ WHERE iso_3166_1_a2 = "VN";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Vanuatais"
+ WHERE iso_3166_1_a2 = "VU";
+
+UPDATE geoloc_countries
+ SET nationalityFR = NULL, belongsTo = "FR", capital = "Mata-Utu"
+ WHERE iso_3166_1_a2 = "WF";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Yéménite", capital = "Sanaa"
+ WHERE iso_3166_1_a2 = "YE";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Zambien"
+ WHERE iso_3166_1_a2 = "ZM";
+
+UPDATE geoloc_countries
+ SET nationalityFR = "Zimbabwéen"
+ WHERE iso_3166_1_a2 = "ZW";
+
+-- vim:set syntax=mysql: