X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fgeoloc.php;h=e4b549eca5c4d8b9ad2c077951ee87a456513441;hb=c15afc4e9844238cab4173022b3ef40d0dc9585d;hp=cfcd673292f97beb5390519ac9eb66f8316f5d59;hpb=27472b8575b2ba4ec4d7922891d17f48b3ff435f;p=platal.git diff --git a/modules/geoloc.php b/modules/geoloc.php index cfcd673..e4b549e 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -1,6 +1,6 @@ $this->make_hook('icon', AUTH_COOKIE), 'geoloc' => $this->make_hook('default', AUTH_COOKIE), - 'geoloc/icon.swf' => $this->make_hook('icon', AUTH_COOKIE), - 'geoloc/dynamap.swf' => $this->make_hook('dynamap', AUTH_COOKIE), - 'geoloc/init' => $this->make_hook('init', AUTH_COOKIE), - 'geoloc/city' => $this->make_hook('city', AUTH_COOKIE), - 'geoloc/country' => $this->make_hook('country', AUTH_COOKIE), +// 'geoloc/icon.swf' => $this->make_hook('icon', AUTH_COOKIE), +// 'geoloc/dynamap.swf' => $this->make_hook('dynamap', AUTH_COOKIE), +// 'geoloc/init' => $this->make_hook('init', AUTH_COOKIE), +// 'geoloc/city' => $this->make_hook('city', AUTH_COOKIE), +// 'geoloc/country' => $this->make_hook('country', AUTH_COOKIE), '%grp/geoloc' => $this->make_hook('default',AUTH_COOKIE), '%grp/geoloc/icon.swf' => $this->make_hook('icon', AUTH_COOKIE), '%grp/geoloc/dynamap.swf'=> $this->make_hook('dynamap',AUTH_COOKIE), @@ -54,25 +55,36 @@ class GeolocModule extends PLModule return $querystring; } - function handler_default(&$page) + function use_map() + { + return is_file(dirname(__FILE__).'/geoloc/dynamap.swf') && + is_file(dirname(__FILE__).'/geoloc/icon.swf'); + } + + function handler_default(&$page, $action = null, $subaction = null) { global $globals; - if (!is_file(dirname(__FILE__).'/geoloc/dynamap.swf') || - !is_file(dirname(__FILE__).'/geoloc/icon.swf')) + $set = new UserSet(); + $set->addMod('geoloc', 'Geolocalisation', true); + $set->apply('geoloc', $page, $action, $subaction); + return; + + if (!$this->use_map()) $page->assign('request_geodesix', 1); if (!empty($GLOBALS['IS_XNET_SITE'])) { - $page->useMenu(); - $page->setType($globals->asso('cat')); $page->assign('no_annu', 1); + new_annu_page('geoloc/index.tpl'); + } else { + $page->changeTpl('geoloc/index.tpl'); } - require_once 'search.inc.php'; - $page->changeTpl('geoloc/index.tpl'); + require_once dirname(__FILE__).'/search/search.inc.php'; + $fields = new SFieldGroup(true, advancedSearchFromInput()); $search = str_replace('&','&',$fields->get_url()); - if (!Env::has('only_current')) + if ((!Env::has('only_current') && !Env::has('rechercher')) || Env::v('only_current') == 'on') $search .= '&only_current=on'; elseif (Env::i('only_current') != 'on') $search .= '&only_current='; @@ -80,6 +92,7 @@ class GeolocModule extends PLModule $search = preg_replace('/(^|&)mapid=([0-9]+)(&)/','\1\3', $search); if ($search) $search = '?'.$search; + $page->assign('search_nourlencode',$search); $page->assign('search',urlencode($search)); $page->assign('protocole', substr($globals->baseurl,0,strpos($globals->baseurl,':'))); @@ -121,7 +134,7 @@ class GeolocModule extends PLModule { global $globals; - $page->changeTpl('geoloc/geolocInit.tpl', NO_SKIN); + $page->changeTpl('geoloc/init.tpl', NO_SKIN); header('Content-type: text/xml'); header('Pragma:'); @@ -137,10 +150,10 @@ class GeolocModule extends PLModule header("Content-type: text/xml"); header("Pragma:"); - $page->changeTpl('geoloc/getCityInfos.tpl', NO_SKIN); + $page->changeTpl('geoloc/city.tpl', NO_SKIN); + require_once dirname(__FILE__).'/search/search.inc.php'; require_once('geoloc.inc.php'); - require_once('search.inc.php'); if (empty($GLOBALS['IS_XNET_SITE'])) { $usual_fields = advancedSearchFromInput(); @@ -156,10 +169,11 @@ class GeolocModule extends PLModule if ($where) $where = "WHERE ".$where; $users = XDB::iterator(" - SELECT u.user_id AS id, u.prenom, u.nom, u.promo + SELECT u.user_id AS id, u.prenom, u.nom, u.promo, alias FROM adresses AS a INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid) INNER JOIN auth_user_quick AS q ON(q.user_id = a.uid) + LEFT JOIN aliases ON(u.user_id = aliases.id AND FIND_IN_SET(aliases.flags,'bestalias')) ".$fields->get_select_statement()." ".$where." GROUP BY u.user_id LIMIT 11", $id); @@ -173,15 +187,15 @@ class GeolocModule extends PLModule // to debug sql use the next line if (Env::has('debug')) { - $page->changeTpl('geoloc/getData.tpl', SIMPLE); + $page->changeTpl('geoloc/country.tpl', SIMPLE); } else { header("Content-type: text/xml"); header("Pragma:"); - $page->changeTpl('geoloc/getData.tpl', NO_SKIN); + $page->changeTpl('geoloc/country.tpl', NO_SKIN); } + require_once dirname(__FILE__).'/search/search.inc.php'; require_once 'geoloc.inc.php'; - require_once 'search.inc.php'; $querystring = $this->_make_qs(); $page->assign('searchvars', $querystring); @@ -218,7 +232,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->trig(($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()); @@ -230,7 +244,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->trig("Impossible d'accéder au webservice"); else $refresh = true; } @@ -247,7 +261,7 @@ class GeolocModule extends PLModule 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->trig("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"); @@ -269,4 +283,5 @@ class GeolocModule extends PLModule } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>