facilite l'upgrade vers 0.9.10
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 17 Jun 2006 23:41:03 +0000 (23:41 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 17 Jun 2006 23:41:03 +0000 (23:41 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@320 839d8a87-29fc-0310-9880-83ba4fa771e5

bin/change.year.sh [deleted file]
htdocs/admin/geoloc_dynamap.php
include/geoloc.inc.php
templates/admin/geoloc_dynamap.tpl
upgrade/0.9.10/02_tels.sql

diff --git a/bin/change.year.sh b/bin/change.year.sh
deleted file mode 100755 (executable)
index d6af1e4..0000000
+++ /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
index a7feae5..b479c73 100644 (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();
 
index 43ed1f1..ea247fb 100644 (file)
@@ -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;
 }
 // }}}
index 0d37d23..28981bc 100644 (file)
 {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: *}
index 8022145..4af773b 100644 (file)
@@ -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`;