X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fgeoloc.php;h=cc437ea181bd502320e3c62b86b5a26892f33987;hb=f3da6d81799c3ee012f1ca5f86aac9fc01d5818e;hp=500e20db55dfef654da9072d07cb376fd9667b6d;hpb=a7de4ef724d1a3b0bf978a50ce7cc9d23412c7a0;p=platal.git diff --git a/modules/geoloc.php b/modules/geoloc.php index 500e20d..cc437ea 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -25,188 +25,18 @@ class GeolocModule extends PLModule { return array( '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), 'admin/geoloc' => $this->make_hook('admin', AUTH_MDP, 'admin'), 'admin/geoloc/dynamap' => $this->make_hook('admin_dynamap', AUTH_MDP, 'admin'), ); } - function _make_qs() - { - $querystring = ""; - - foreach ($_GET as $v => $a) { - if ($v != 'initfile' && $v != 'n' && $v != 'mapid') { - $querystring .= urlencode($v).'='.urlencode($a).'&'; - } - } - - return $querystring; - } - - function use_map() - { - return is_file(dirname(__FILE__).'/geoloc/dynamap.swf') && - is_file(dirname(__FILE__).'/geoloc/icon.swf'); - } - - function handler_default(&$page) - { - global $globals; - - if (!$this->use_map()) - $page->assign('request_geodesix', 1); - - if (!empty($GLOBALS['IS_XNET_SITE'])) { - $page->assign('no_annu', 1); - new_annu_page('geoloc/index.tpl'); - } else { - $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') && !Env::has('rechercher')) || Env::v('only_current') == 'on') - $search .= '&only_current=on'; - elseif (Env::i('only_current') != 'on') - $search .= '&only_current='; - - $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,':'))); - - 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) - { - global $globals; - - header("Content-type: application/x-shockwave-flash"); - header("Pragma:"); - - readfile(dirname(__FILE__).'/geoloc/icon.swf'); - exit; - - return PL_NOT_FOUND; - } - - function handler_dynamap(&$page) - { - global $globals; - - header("Content-type: application/x-shockwave-flash"); - - header("Pragma:"); - readfile(dirname(__FILE__).'/geoloc/dynamap.swf'); - exit; - - return PL_NOT_FOUND; - } - - function handler_init(&$page) - { - global $globals; - - $page->changeTpl('geoloc/init.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()); - } - - function handler_city(&$page) - { - global $globals; - - header("Content-type: text/xml"); - header("Pragma:"); - - $page->changeTpl('geoloc/city.tpl', NO_SKIN); - - require_once dirname(__FILE__).'/search/search.inc.php'; - require_once('geoloc.inc.php'); - - 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; - - $users = XDB::iterator(" - 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); - - $page->assign('users', $users); - } - - function handler_country(&$page) + function handler_default(&$page, $action = null, $subaction = null) { global $globals; - // to debug sql use the next line - if (Env::has('debug')) { - $page->changeTpl('geoloc/country.tpl', SIMPLE); - } else { - header("Content-type: text/xml"); - header("Pragma:"); - $page->changeTpl('geoloc/country.tpl', NO_SKIN); - } - - require_once dirname(__FILE__).'/search/search.inc.php'; - require_once 'geoloc.inc.php'; - - $querystring = $this->_make_qs(); - $page->assign('searchvars', $querystring); - - $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, $fields, 10); - - $page->assign('countries', $countries); - $page->assign('cities', $cities); + $set = new UserSet(); + $set->addMod('geoloc', 'Geolocalisation', true); + $set->apply('geoloc', $page, $action, $subaction); } function handler_admin(&$page, $action = false) {