geoloc pour xnet
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 25 Jul 2006 12:59:24 +0000 (12:59 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 25 Jul 2006 12:59:24 +0000 (12:59 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@645 839d8a87-29fc-0310-9880-83ba4fa771e5

14 files changed:
htdocs.net/.htaccess
htdocs.net/groupe/dynamap.php [deleted file]
htdocs.net/groupe/geoloc.php [deleted file]
htdocs.net/groupe/geolocInit.php [deleted file]
htdocs.net/groupe/getCityInfos.php [deleted file]
htdocs.net/groupe/getData.php [deleted file]
htdocs.net/groupe/icon.php [deleted file]
htdocs.net/index.php
include/geoloc.inc.php
include/xnet/page.inc.php
modules/geoloc.php
templates/geoloc/geolocInit.tpl
templates/geoloc/getData.tpl
templates/geoloc/index.tpl

index 6e2ffaa..c5457d6 100644 (file)
@@ -1,7 +1,7 @@
 Options +FollowSymLinks
 RewriteEngine on
 
-RewriteBase /~x2000habouzit
+RewriteBase /~x2001corpet
 
 # Rewrite URLs of the form 'index.php?q=x':
 RewriteCond %{REQUEST_FILENAME} !-f
diff --git a/htdocs.net/groupe/dynamap.php b/htdocs.net/groupe/dynamap.php
deleted file mode 100644 (file)
index 07410a4..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-
-require_once('xnet.inc.php');
-
-$querystring = "";
-foreach ($_GET as $v => $a)
-       if ($v != 'initfile')
-               $querystring .= '&'.urlencode($v).'='.urlencode($a);
-$initfile = urlencode('geolocInit.php?'.$querystring);
-
-if (urlencode(Env::v('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);
-
-?>
diff --git a/htdocs.net/groupe/geoloc.php b/htdocs.net/groupe/geoloc.php
deleted file mode 100644 (file)
index c0164bc..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-
-if ($globals->asso('pub') == 'public') {
-    new_group_page('geoloc/index.tpl');
-} else {
-    new_groupadmin_page('geoloc/index.tpl');
-}
-
-$page->assign('no_annu', true);
-$page->assign('dynamap_vars', 'none');
-$page->run();
-
-?>
diff --git a/htdocs.net/groupe/geolocInit.php b/htdocs.net/groupe/geolocInit.php
deleted file mode 100644 (file)
index 6026a30..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php 
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('xnet.inc.php');
-
-header("Content-type: text/xml");
-new_nonhtml_page('geoloc/geolocInit.tpl');
-
-$page->assign('background', '#F4FAD4');
-$page->run();
-?>
diff --git a/htdocs.net/groupe/getCityInfos.php b/htdocs.net/groupe/getCityInfos.php
deleted file mode 100644 (file)
index eda7d7d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require 'xnet.inc.php';
-
-
-header("Content-type: text/xml");
-
-new_nonhtml_page('geoloc/getCityInfos.tpl');
-
-require_once('geoloc.inc.php');
-require_once('search.inc.php');
-
-$_REQUEST['asso_id'] = $globals->asso('id');
-$_REQUEST['only_current'] = 1;
-$assoField   = new RefSField('asso_id',array('gxm.asso_id'),'groupex.membres','gxm','u.user_id=gxm.uid');
-$cityIdField    = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
-
-$fields = new SFieldGroup(true, array($assoField, $cityIdField));
-$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
-      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)
-        ".$fields->get_select_statement()."
-        ".$where."
-     GROUP BY u.user_id LIMIT 11",
-        $id);
-
-if ($globals->asso('pub') == 'public' || S::has_perms())
-    $page->assign('users', $users);
-
-$page->run();
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
-?>
diff --git a/htdocs.net/groupe/getData.php b/htdocs.net/groupe/getData.php
deleted file mode 100644 (file)
index 62203a3..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require 'xnet.inc.php';
-
-new_nonhtml_page('geoloc/getData.tpl');
-$nodata = ($globals->asso('pub') != 'public') && !S::has_perms();
-
-header("Content-type: text/xml");
-
-require_once('geoloc.inc.php');
-require_once('search.inc.php');
-
-$querystring = "";
-foreach ($_GET as $v => $a)
-       if ($v != 'mapid')
-               $querystring .= urlencode($v).'='.urlencode($a).'&amp;';
-$page->assign('searchvars', $querystring);
-if (Env::has('mapid'))
-    $mapid = Env::i('mapid', -2);
-else
-    $mapid = false;
-
-$_REQUEST['asso_id'] = $globals->asso('id');
-$_REQUEST['only_current'] = 1;
-$assoField   = new RefSField('asso_id',array('gxm.asso_id'),'groupex.membres','gxm','u.user_id=gxm.uid');
-
-if (!$nodata) {
-    list($countries, $cities) = geoloc_getData_subcountries($mapid, array($assoField), 10);
-    $page->assign('countries', $countries);
-    $page->assign('cities', $cities);
-}
-
-$page->run();
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
-?>
diff --git a/htdocs.net/groupe/icon.php b/htdocs.net/groupe/icon.php
deleted file mode 100644 (file)
index fb284e0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-
-require_once('xnet.inc.php');
-
-new_nonhtml_page('');
-
-header("Content-type: application/x-shockwave-flash");
-
-if ($globals->geoloc->use_map) {
-    readfile($globals->geoloc->icon_path);
-}
-
-?>
index a3896b6..e60b157 100644 (file)
@@ -24,7 +24,8 @@ require 'xnet.inc.php';
 require_once dirname(__FILE__).'/../classes/Xnet.php';
 require_once dirname(__FILE__).'/../classes/PLModule.php';
 
-$platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents');
+$GLOBALS['IS_XNET_SITE'] = true;
+$platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc');
 $platal->run();
 
 ?>
index c23f726..133d6ea 100644 (file)
@@ -127,6 +127,7 @@ function get_new_maps($url)
     XDB::execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1));
     return true;
 }
+// }}}
 
 // {{{ get_address_text($adr)
 /** make the text of an address that can be read by a mailman
index 7bb8971..a110793 100644 (file)
@@ -81,7 +81,7 @@ class XnetPage extends PlatalPage
             if (may_update() || $globals->asso('pub') == 'public') {
                 $sub['annuaire du groupe'] = "$dim/annuaire";
                 if ($globals->xnet->geoloc)
-                    $sub['carte'] = "$dim/geoloc.php";
+                    $sub['carte'] = "$dim/geoloc";
             }
             if ($globals->asso('mail_domain')) {
                 $sub['listes de diffusion'] = "$dim/lists";
index 9a4bb4d..133e24a 100644 (file)
@@ -30,6 +30,12 @@ class GeolocModule extends PLModule
             '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),
         );
     }
 
@@ -50,10 +56,18 @@ class GeolocModule extends PLModule
     {
         global $globals;
 
-        require_once 'search.inc.php';
+        if (!is_file(dirname(__FILE__).'/geoloc/dynamap.swf') ||
+             !is_file(dirname(__FILE__).'/geoloc/icon.swf'))
+            $page->assign('request_geodesix', 1);
 
-        $page->changeTpl('geoloc/index.tpl');
+        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'))
@@ -64,8 +78,7 @@ class GeolocModule extends PLModule
         $search = preg_replace('/(^|&amp;)mapid=([0-9]+)(&amp;|$)/','\1\3', $search);
         if ($search)
             $search = '?'.$search;
-        $initfile = urlencode('geoloc/init'.$search);
-        $page->assign('flashvars','initfile='.$initfile);
+        $page->assign('search',$search);
 
         $page->assign('protocole', substr($globals->baseurl,0,strpos($globals->baseurl,':')));
 
@@ -83,10 +96,8 @@ class GeolocModule extends PLModule
         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;
     }
@@ -97,11 +108,9 @@ class GeolocModule extends PLModule
 
         header("Content-type: application/x-shockwave-flash");
 
-        if ($globals->geoloc->use_map) {
-            header("Pragma:");
-            readfile($globals->geoloc->dynamap_path);
-            exit;
-        }
+        header("Pragma:");
+        readfile(dirname(__FILE__).'/geoloc/dynamap.swf');
+        exit;
 
         return PL_NOT_FOUND;
     }
@@ -114,6 +123,8 @@ class GeolocModule extends PLModule
 
         header('Content-type: text/xml');
         header('Pragma:');
+        if(!empty($GLOBALS['IS_XNET_SITE']))
+            $page->assign('background', 0xF2E9D0);               
         $page->assign('querystring', $this->_make_qs());
     }
 
@@ -129,8 +140,16 @@ class GeolocModule extends PLModule
         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;
 
@@ -166,8 +185,15 @@ class GeolocModule extends PLModule
         $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, advancedSearchFromInput(), 10);
+        list($countries, $cities) = geoloc_getData_subcountries($mapid, $fields, 10);
 
         $page->assign('countries', $countries);
         $page->assign('cities', $cities);
index ead89a1..b3beaf9 100644 (file)
@@ -41,7 +41,8 @@ textSeeMapOfCity="Voir la carte de "
 textYouHaveSelected="Tu as sélectionné "\r
 {if $background}\r
 background="{$background}"\r
+zoomBarBackgroundColor="{$background}"\r
 {/if} \r
 textCopyright="Les règles de l'annuaire s'appliquent aussi à cette application"\r
-iconSwf="geoloc/icon.swf"\r
-scriptInfosArea="geoloc/country?{$querystring}"/>\r
+iconSwf="{$platal->ns}geoloc/icon.swf"\r
+scriptInfosArea="{$platal->ns}geoloc/country?{$querystring}"/>\r
index a5e55d3..b133ba5 100644 (file)
@@ -30,7 +30,7 @@
       {if $country.nbPop > 0 or $country.id eq 0}\r
       <map x="{$country.x}" y="{$country.y}" height="{$country.height}" width="{$country.width}" ratio="{$country.rat}"/>\r
       <icon x="{$country.xPop}" y="{$country.yPop}" nb="{$country.nbPop}" size="{$country.rad}" name="{$country.name|utf8_encode}" green="{if $country.nbPop}{$country.yellow/$country.nbPop}{else}0{/if}" blue="0" alpha="0.7"/>\r
-      <moreinfos url="geoloc/country?{$searchvars}mapid={$country.id}"/>\r
+      <moreinfos url="{$platal->ns}geoloc/country?{$searchvars}mapid={$country.id}"/>\r
       {/if}\r
     </country>\r
     {/foreach}\r
@@ -39,7 +39,7 @@
     {foreach from=$cities item="city"}\r
     <city id="{$city.id}" name="{$city.name}">\r
       <icon x="{$city.x}" y="{$city.y}" nb="{$city.pop}" size="{$city.size}" name="{$city.name}" green="{if $city.pop}{$city.yellow/$city.pop}{else}0{/if}" blue="0"/>\r
-      <moreinfos url="geoloc/city?{$searchvars}cityid={$city.id}"/>\r
+      <moreinfos url="{$platal->ns}geoloc/city?{$searchvars}cityid={$city.id}"/>\r
     </city>\r
     {/foreach}\r
   </cities>\r
index 91b3fbc..9518308 100644 (file)
@@ -26,7 +26,7 @@
 {literal}
 function ficheXorg(id)
 {
-  window.open('profile/'+id,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=840,height=600');
+  window.open('{/literal}{if $no_annu}https://www.polytechnique.org/{/if}{literal}profile/'+id,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=840,height=600');
 }
 {/literal}
 {if !$no_annu}
@@ -62,10 +62,10 @@ function searchMapId(f)
     Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles.
   </p>
 {/if}
-{if $globals->geoloc->use_map}
+{if !$request_geodesix}
   <p class="center">
     <embed
-      src="geoloc/dynamap.swf"
+      src="{$platal->ns}geoloc/dynamap.swf"
       quality="high"
       bgcolor="#ffffff"
       width="600"
@@ -73,7 +73,7 @@ function searchMapId(f)
       name="dynamap"
       id="dynamap"
       align="middle"
-      flashvars="{$flashvars}"
+      flashvars="initfile={$platal->ns}geoloc%2Finit{$search}"
       type="application/x-shockwave-flash"
       menu="false"
       wmode="opaque"