+++ /dev/null
-find ./ -type f | grep -v svn | xargs sed -i 's/Copyright (C) 2003-2006/Copyright (C) 2003-2006/'
\ No newline at end of file
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", "<meta http-equiv='Refresh' content='3'/>");
+}
$page->assign("nb_cities_not_on_map", $missing);
+$page->assign("no_smallest", $noSmallest);
$page->run();
}
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;
}
// }}}
{else}
<p> Toutes les villes de la base sont placées dans des cartes. </p>
{/if}
+{if $no_smallest}
+ <p>
+ Il faut <a href='?fix=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}
{* vim:set et sw=2 sts=2 sws=2: *}
`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`;