X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fgeoloc.php;h=133e24a65ebacf14bb84164aeda69b9433dcab4c;hb=a2fa0614a1d25f19f34462f6b21e4fc032619133;hp=3ea7f4f417b1ba411939ceede109b5878873cbb8;hpb=801fcad813666310da1ca5b6f07f91cfed1abbee;p=platal.git diff --git a/modules/geoloc.php b/modules/geoloc.php index 3ea7f4f..133e24a 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -24,12 +24,18 @@ class GeolocModule extends PLModule function handlers() { return array( - 'geoloc' => $this->make_hook('default', AUTH_COOKIE), - 'geoloc/icon.php' => $this->make_hook('icon', AUTH_COOKIE), - 'geoloc/dynamap.php' => $this->make_hook('dynamap', AUTH_COOKIE), - 'geoloc/geolocInit.php' => $this->make_hook('init', AUTH_COOKIE), - 'geoloc/getCityInfos.php' => $this->make_hook('city', AUTH_COOKIE), - 'geoloc/getData.php' => $this->make_hook('data', 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), + '%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), + '%grp/geoloc/init' => $this->make_hook('init', AUTH_COOKIE), + '%grp/geoloc/city' => $this->make_hook('city', AUTH_COOKIE), + '%grp/geoloc/country' => $this->make_hook('country',AUTH_COOKIE), ); } @@ -38,8 +44,8 @@ class GeolocModule extends PLModule $querystring = ""; foreach ($_GET as $v => $a) { - if ($v != 'initfile') { - $querystring .= '&'.urlencode($v).'='.urlencode($a); + if ($v != 'initfile' && $v != 'p' && $v != 'mapid') { + $querystring .= urlencode($v).'='.urlencode($a).'&'; } } @@ -50,25 +56,37 @@ class GeolocModule extends PLModule { global $globals; - require_once 'search.inc.php'; - - $page->changeTpl('geoloc/index.tpl'); + if (!is_file(dirname(__FILE__).'/geoloc/dynamap.swf') || + !is_file(dirname(__FILE__).'/geoloc/icon.swf')) + $page->assign('request_geodesix', 1); - $res = XDB::query('SELECT COUNT(DISTINCT uid) - FROM adresses WHERE cityid IS NOT NULL'); - $page->assign('localises', $res->fetchOneCell()); + if (!empty($GLOBALS['IS_XNET_SITE'])) { + $page->useMenu(); + $page->setType($globals->asso('cat')); + $page->assign('no_annu', 1); + } + require_once 'search.inc.php'; + $page->changeTpl('geoloc/index.tpl'); $fields = new SFieldGroup(true, advancedSearchFromInput()); $search = $fields->get_url(); - if (Env::has('only_current') && Env::get('only_current') != 'on') { + if (!Env::has('only_current')) + $search .= '&only_current=on'; + elseif (Env::get('only_current') != 'on') $search .= '&only_current='; - } + $search = preg_replace('/(^|&)mapid=([0-9]+)(&|$)/','\1\3', $search); - if ($search) { - $page->assign('dynamap_vars', $search); - } + if ($search) + $search = '?'.$search; + $page->assign('search',$search); - $page->assign('use_map', $globals->geoloc->use_map()); + $page->assign('protocole', substr($globals->baseurl,0,strpos($globals->baseurl,':'))); + + if (!$search) { + $res = XDB::query('SELECT COUNT(DISTINCT uid) + FROM adresses WHERE cityid IS NOT NULL'); + $page->assign('localises', $res->fetchOneCell()); + } } function handler_icon(&$page) @@ -76,11 +94,10 @@ class GeolocModule extends PLModule global $globals; header("Content-type: application/x-shockwave-flash"); + header("Pragma:"); - if ($globals->geoloc->use_map()) { - readfile($globals->geoloc->icon_path); - exit; - } + readfile(dirname(__FILE__).'/geoloc/icon.swf'); + exit; return PL_NOT_FOUND; } @@ -89,20 +106,11 @@ class GeolocModule extends PLModule { global $globals; - $querystring = $this->_make_qs(); - $initfile = urlencode('geolocInit.php?'.$querystring); - - if (urlencode(Env::get('initfile')) != $initfile) { - header("Location: dynamap.php?initfile=$initfile{$querystring}"); - die(); - } - header("Content-type: application/x-shockwave-flash"); - if ($globals->geoloc->use_map()) { - readfile($globals->geoloc->dynamap_path); - exit; - } + header("Pragma:"); + readfile(dirname(__FILE__).'/geoloc/dynamap.swf'); + exit; return PL_NOT_FOUND; } @@ -114,6 +122,9 @@ class GeolocModule extends PLModule $page->changeTpl('geoloc/geolocInit.tpl', NO_SKIN); header('Content-type: text/xml'); + header('Pragma:'); + if(!empty($GLOBALS['IS_XNET_SITE'])) + $page->assign('background', 0xF2E9D0); $page->assign('querystring', $this->_make_qs()); } @@ -122,14 +133,23 @@ class GeolocModule extends PLModule global $globals; header("Content-type: text/xml"); + header("Pragma:"); $page->changeTpl('geoloc/getCityInfos.tpl', NO_SKIN); require_once('geoloc.inc.php'); require_once('search.inc.php'); - $usual_fields = advancedSearchFromInput(); - $fields = new SFieldGroup(true, $usual_fields); + if (empty($GLOBALS['IS_XNET_SITE'])) { + $usual_fields = advancedSearchFromInput(); + $fields = new SFieldGroup(true, $usual_fields); + } else { + $_REQUEST['asso_id'] = $globals->asso('id'); + $_REQUEST['only_current'] = 'on'; + $fields = new SFieldGroup(true, array( + new RefSField('asso_id',array('gxm.asso_id'),'groupex.membres','gxm','u.user_id=gxm.uid'), + new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av')))); + } $where = $fields->get_where_statement(); if ($where) $where = "WHERE ".$where; @@ -145,16 +165,16 @@ class GeolocModule extends PLModule $page->assign('users', $users); } - function handler_data(&$page) + function handler_country(&$page) { global $globals; // 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"); + header("Pragma:"); $page->changeTpl('geoloc/getData.tpl', NO_SKIN); } @@ -164,9 +184,16 @@ 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; + if (empty($GLOBALS['IS_XNET_SITE'])) { + $fields = advancedSearchFromInput(); + } else { + $_REQUEST['asso_id'] = $globals->asso('id'); + $_REQUEST['only_current'] = 'on'; + $fields = array(new RefSField('asso_id',array('gxm.asso_id'),'groupex.membres','gxm','u.user_id=gxm.uid')); + } - list($countries, $cities) = geoloc_getData_subcountries($mapid, advancedSearchFromInput(), 10); + list($countries, $cities) = geoloc_getData_subcountries($mapid, $fields, 10); $page->assign('countries', $countries); $page->assign('cities', $cities);