X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fgeoloc.php;h=ae45b22525449ede2ee1bacea8f617472cc68af2;hb=f4035298fd421e87b9a58f6a801b53da348613de;hp=d9d73585f5ee6a1bfce48c678edf18f8cd72f96d;hpb=787bb3d745141f2f85bd947ad7dd775d2c63f908;p=platal.git diff --git a/modules/geoloc.php b/modules/geoloc.php index d9d7358..ae45b22 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -1,6 +1,6 @@ $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') ); } @@ -42,7 +43,7 @@ class GeolocModule extends PLModule function handler_admin(&$page, $action = false) { $page->changeTpl('geoloc/admin.tpl'); require_once("geoloc.inc.php"); - $page->assign('xorg_title','Polytechnique.org - Administration - Geolocalisation'); + $page->setTitle('Administration - Geolocalisation'); $nb_synchro = 0; @@ -56,7 +57,7 @@ class GeolocModule extends PLModule } if ($nb_synchro) - $page->trig(($nb_synchro > 1)?($nb_synchro." villes ont été synchronisées"):"Une ville a été synchronisée"); + $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()); @@ -68,7 +69,7 @@ class GeolocModule extends PLModule if ($action == 'cities_not_on_map') { require_once('geoloc.inc.php'); if (!fix_cities_not_on_map(20)) - $page->trig("Impossible d'accéder au webservice"); + $page->trigError("Impossible d'accéder au webservice"); else $refresh = true; } @@ -79,13 +80,15 @@ class GeolocModule extends PLModule } 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"); + 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->trig("Impossible d'accéder aux nouvelles cartes"); + $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"); @@ -98,13 +101,58 @@ class GeolocModule extends PLModule $noCoordinates = $countNoCoordinates->fetchOneCell(); if (isset($refresh) && $missing) { - $page->assign("xorg_extra_header", ""); + $page->assign("pl_extra_header", ""); } $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: