From 014c846464523ca58669146df64d2ac01957c951 Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Sat, 17 Jun 2006 23:41:03 +0000 Subject: [PATCH] facilite l'upgrade vers 0.9.10 git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@320 839d8a87-29fc-0310-9880-83ba4fa771e5 --- bin/change.year.sh | 1 - htdocs/admin/geoloc_dynamap.php | 28 ++++++++++++++++++---------- include/geoloc.inc.php | 27 ++++++++++++++++----------- templates/admin/geoloc_dynamap.tpl | 5 +++++ upgrade/0.9.10/02_tels.sql | 4 ++-- 5 files changed, 41 insertions(+), 24 deletions(-) delete mode 100755 bin/change.year.sh diff --git a/bin/change.year.sh b/bin/change.year.sh deleted file mode 100755 index d6af1e4..0000000 --- a/bin/change.year.sh +++ /dev/null @@ -1 +0,0 @@ -find ./ -type f | grep -v svn | xargs sed -i 's/Copyright (C) 2003-2006/Copyright (C) 2003-2006/' \ No newline at end of file diff --git a/htdocs/admin/geoloc_dynamap.php b/htdocs/admin/geoloc_dynamap.php index a7feae5..b479c73 100644 --- a/htdocs/admin/geoloc_dynamap.php +++ b/htdocs/admin/geoloc_dynamap.php @@ -22,28 +22,36 @@ require_once("xorg.inc.php"); new_admin_page('admin/geoloc_dynamap.tpl'); -if (Env::get('fix') == 'cities_not_on_map') -{ +if (Env::get('fix') == 'cities_not_on_map') { require_once('geoloc.inc.php'); - if (!fix_cities_not_on_map(100)) + if (!fix_cities_not_on_map(20)) $page->trig("Impossible d'accéder au webservice"); else $refresh = true; } -if (Env::has('new_maps')) -{ - require_once('geoloc.inc.php'); - if (!get_new_maps(Env::get('url'))) - $page->trig("Impossible d'accéder aux nouvelles cartes"); +if (Env::get('fix') == 'smallest_maps') { + require_once('geoloc.inc.php'); + set_smallest_levels(); +} + +if (Env::has('new_maps')) { + require_once('geoloc.inc.php'); + if (!get_new_maps(Env::get('url'))) + $page->trig("Impossible d'accéder aux nouvelles cartes"); } $countMissing = $globals->xdb->query("SELECT COUNT(*) FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL"); $missing = $countMissing->fetchOneCell(); -if (isset($refresh) && $missing) - header('Refresh: 3'); +$countNoSmallest = $globals->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; + +if (isset($refresh) && $missing) { + $page->assign("xorg_extra_header", ""); +} $page->assign("nb_cities_not_on_map", $missing); +$page->assign("no_smallest", $noSmallest); $page->run(); diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index 43ed1f1..ea247fb 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -273,18 +273,23 @@ function fix_cities_not_on_map($limit=false) } else return false; + return true; +} - $maxlevelquery = $globals->xdb->query("SELECT MAX(level) FROM geoloc_maps"); - $maxlevel = $maxlevelquery->fetchOneCell(); - for ($level = $maxlevel; $level >= 0; $level--) - $globals->xdb->query(" - UPDATE geoloc_city AS gc - INNER JOIN geoloc_city_in_maps AS gcim ON(gc.id = gcim.city_id) - INNER JOIN geoloc_maps AS gm ON(gm.id = gcim.map_id AND gm.level = {?}) - LEFT JOIN geoloc_city_in_maps AS gcim2 ON(gc.id = gcim2.city_id AND gcim2.infos = 'smallest') - SET gcim.infos = 'smallest' - WHERE gcim2.city_id IS NULL", $level); - +function set_smallest_levels() { + global $globals; + $maxlengths = $globals->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()) { + $globals->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; } // }}} diff --git a/templates/admin/geoloc_dynamap.tpl b/templates/admin/geoloc_dynamap.tpl index 0d37d23..28981bc 100644 --- a/templates/admin/geoloc_dynamap.tpl +++ b/templates/admin/geoloc_dynamap.tpl @@ -45,5 +45,10 @@ {else}

Toutes les villes de la base sont placées dans des cartes.

{/if} +{if $no_smallest} +

+ Il faut définir la plus petite carte pour chaque ville (à ne faire qu'une fois quand on a placé toutes les villes). +

+{/if} {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/upgrade/0.9.10/02_tels.sql b/upgrade/0.9.10/02_tels.sql index 8022145..4af773b 100644 --- a/upgrade/0.9.10/02_tels.sql +++ b/upgrade/0.9.10/02_tels.sql @@ -6,8 +6,8 @@ CREATE TABLE `tels` ( `tel_pub` enum('private','ax','public') NOT NULL default 'private', `tel` varchar(30) NOT NULL default '', PRIMARY KEY (`uid`,`adrid`,`telid`) - ) + ); INSERT INTO tels SELECT uid, adrid, 0, 'Tél.', tel_pub, tel FROM adresses; INSERT INTO tels SELECT uid, adrid, 1, 'Fax', tel_pub, fax FROM adresses; DELETE FROM tels WHERE tel = ""; -ALTER TABLE `adresses` DROP `tel`, DROP `tel_pub`; \ No newline at end of file +ALTER TABLE `adresses` DROP `tel`, DROP `tel_pub`; -- 2.1.4