Force baseurl because it is used in redirect
[platal.git] / modules / geoloc.php
index db56da2..49f3895 100644 (file)
@@ -54,13 +54,13 @@ class GeolocModule extends PLModule
 
         $page->changeTpl('geoloc/index.tpl');
 
-        $res = $globals->xdb->query('SELECT COUNT(DISTINCT uid)
+        $res = XDB::query('SELECT COUNT(DISTINCT uid)
                                        FROM adresses WHERE cityid IS NOT NULL');
         $page->assign('localises', $res->fetchOneCell());
 
         $fields = new SFieldGroup(true, advancedSearchFromInput());
         $search = $fields->get_url();
-        if (Env::has('only_current') && Env::get('only_current') != 'on') {
+        if (Env::has('only_current') && Env::v('only_current') != 'on') {
             $search .= '&only_current=';
         }
         $search = preg_replace('/(^|&)mapid=([0-9]+)(&|$)/','\1\3', $search);
@@ -69,8 +69,6 @@ class GeolocModule extends PLModule
         }
 
         $page->assign('use_map', $globals->geoloc->use_map());
-
-        return PL_OK;
     }
 
     function handler_icon(&$page)
@@ -94,7 +92,7 @@ class GeolocModule extends PLModule
         $querystring = $this->_make_qs();
         $initfile    = urlencode('geolocInit.php?'.$querystring);
 
-        if (urlencode(Env::get('initfile')) != $initfile) {
+        if (urlencode(Env::v('initfile')) != $initfile) {
             header("Location: dynamap.php?initfile=$initfile{$querystring}");
             die();
         }
@@ -113,12 +111,10 @@ class GeolocModule extends PLModule
     {
         global $globals;
 
-        new_nonhtml_page('geoloc/geolocInit.tpl', AUTH_COOKIE);
+        $page->changeTpl('geoloc/geolocInit.tpl', NO_SKIN);
 
         header('Content-type: text/xml');
         $page->assign('querystring', $this->_make_qs());
-
-        return PL_OK;
     }
 
     function handler_city(&$page)
@@ -127,9 +123,7 @@ class GeolocModule extends PLModule
 
         header("Content-type: text/xml");
 
-        new_nonhtml_page('geoloc/getCityInfos.tpl', AUTH_COOKIE);
-        // to debug sql use the next line
-        //new_skinned_page('', AUTH_COOKIE);
+        $page->changeTpl('geoloc/getCityInfos.tpl', NO_SKIN);
 
         require_once('geoloc.inc.php');
         require_once('search.inc.php');
@@ -139,7 +133,7 @@ class GeolocModule extends PLModule
         $where = $fields->get_where_statement();
         if ($where) $where = "WHERE ".$where;
 
-        $users = $globals->xdb->iterator("
+        $users = XDB::iterator("
             SELECT u.user_id AS id, u.prenom, u.nom, u.promo
               FROM adresses AS a 
         INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid)
@@ -149,8 +143,6 @@ class GeolocModule extends PLModule
              GROUP BY u.user_id LIMIT 11", $id);
 
         $page->assign('users', $users);
-
-        return PL_OK;
     }
 
     function handler_data(&$page)
@@ -159,11 +151,10 @@ class GeolocModule extends PLModule
 
         // to debug sql use the next line
         if (Env::has('debug')) {
-            $page->changeTpl('geoloc/getData.tpl');
-            $page->assign('simple', true);
+            $page->changeTpl('geoloc/getData.tpl', SIMPLE);
         } else {
             header("Content-type: text/xml");
-            new_nonhtml_page('geoloc/getData.tpl', AUTH_COOKIE);
+            $page->changeTpl('geoloc/getData.tpl', NO_SKIN);
         }
 
         require_once 'geoloc.inc.php';
@@ -172,14 +163,12 @@ class GeolocModule extends PLModule
         $querystring = $this->_make_qs();
         $page->assign('searchvars', $querystring);
 
-        $mapid = Env::has('mapid') ? Env::getInt('mapid', -2) : false;
+        $mapid = Env::has('mapid') ? Env::i('mapid', -2) : false;
 
         list($countries, $cities) = geoloc_getData_subcountries($mapid, advancedSearchFromInput(), 10);
 
         $page->assign('countries', $countries);
         $page->assign('cities', $cities);
-
-        return PL_OK;
     }
 }