Some uncommitted work I made before being away.
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 28 Jul 2007 20:05:22 +0000 (20:05 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 28 Jul 2007 20:05:22 +0000 (20:05 +0000)
-> many fixes on the geoloc behaviour
-> initial work on search into contacts

 ChangeLog                           |    1 +
 classes/plset.php                   |    5 ++++-
 include/userset.inc.php             |   23 +++++++++++------------
 modules/carnet.php                  |   23 ++++++++++++++++++-----
 modules/search.php                  |    4 ++--
 modules/search/classes.inc.php      |   15 +++++++++++++--
 modules/search/search.inc.php       |    5 +++--
 templates/include/plview.geoloc.tpl |   31 ++++++++++++++-----------------
 8 files changed, 66 insertions(+), 41 deletions(-)

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1890 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
classes/plset.php
include/userset.inc.php
modules/carnet.php
modules/search.php
modules/search/classes.inc.php
modules/search/search.inc.php
templates/include/plview.geoloc.tpl

index 5b18abb..fb34772 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@ Bug/Wish:
         - Fix GoogleMaps links                                             -FRU
         - #663: Link to Xnet's map from the "My groups" page               -FRU
         - #689: Edit my profile from Xnet                                  -FRU
+        - #692: Layout of the profile                                      -FRU
 
     * Xnet:
         - #694: Color of 'Promotion' groups                                -ALK
index 83322a6..576e864 100644 (file)
@@ -96,7 +96,7 @@ class PlSet
     protected function encodeArgs(array $args, $encode = false)
     {
         $qs = '?';
-        $sep = $encode ? '&' : '&amp;';
+        $sep = '&';
         foreach ($args as $k=>$v) {
             if (!$encode) {
                 $k = urlencode($k);
@@ -161,6 +161,9 @@ class PlSet
             return false;
         }
         $args = $view->args();
+        if (!isset($args['rechercher'])) {
+            $args['rechercher'] = 'Chercher';
+        }
         $page->changeTpl('core/plset.tpl');
         $page->assign('plset_base', $baseurl);
         $page->assign('plset_mods', $this->mods);
index 895f489..a4e6dc7 100644 (file)
@@ -62,7 +62,7 @@ class SearchSet extends UserSet
     private $order = null;
     private $quick = false;
 
-    public function __construct($quick = false, $no_search = false)
+    public function __construct($quick = false, $no_search = false, $join = '', $where = '')
     {
         require_once dirname(__FILE__).'/../modules/search/search.inc.php';
 
@@ -72,13 +72,13 @@ class SearchSet extends UserSet
 
         $this->quick = $quick;
         if ($quick) {
-            $this->getQuick();
+            $this->getQuick($join, $where);
         } else {
-            $this->getAdvanced();
+            $this->getAdvanced($join, $where);
         }
     }
 
-    private function getQuick()
+    private function getQuick($join, $where)
     {
         require_once dirname(__FILE__).'/../modules/search/search.inc.php';
         global $globals;
@@ -91,8 +91,8 @@ class SearchSet extends UserSet
             new ThrowError('Recherche trop générale.');
         }
         $this->score = $qSearch->get_score_statement();
-        parent::__construct("{$fields->get_select_statement()}",
-                            $fields->get_where_statement() .
+        parent::__construct($join . ' ' . $fields->get_select_statement(),
+                            $where . ' ' . $fields->get_where_statement() .
                             (S::logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : ''));
 
         $this->order = implode(',',array_filter(array($fields->get_order_statement(),
@@ -107,8 +107,8 @@ class SearchSet extends UserSet
         if ($fields->too_large()) {
             new ThrowError('Recherche trop générale.');
         }
-        parent::__construct($fields->get_select_statement(),
-                            $fields->get_where_statement());
+        parent::__construct($join . ' ' . $fields->get_select_statement(),
+                            $where . ' ' . $fields->get_where_statement());
         $this->order = implode(',',array_filter(array($fields->get_order_statement(),
                                                       'promo DESC, NomSortKey, prenom')));
     }
@@ -326,8 +326,9 @@ class GeolocView implements PlView
             $page->changeTpl('geoloc/city.tpl', NO_SKIN);
             header('Content-Type: text/xml');
             header('Pragma:');
+            $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
             $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
-                                   "INNER JOIN  adresses AS adrf  ON (adrf.uid = u.user_id)
+                                   "INNER JOIN  adresses AS adrf  ON (adrf.uid = u.user_id $only_current)
                                      LEFT JOIN  aliases  AS al   ON (u.user_id = al.id
                                                                    AND FIND_IN_SET('bestalias', al.flags))
                                     INNER JOIN  adresses AS avg ON (" . getadr_join('avg') . ")",
@@ -354,9 +355,7 @@ class GeolocView implements PlView
             if (!$this->use_map()) {
                 $page->assign('request_geodesix', true);
             }
-            if (!empty($GLOBALS['IS_XNET_SITE'])) {
-                $page->assign('no_annu', true);
-            }
+            $page->assign('annu', @$this->params['with_annu']);
             $page->assign('protocole', @$_SERVER['HTTPS'] ? 'https' : 'http');
             $this->set->get('u.user_id', null, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null);
             return 'include/plview.geoloc.tpl';
index 24bdaaa..108ebdb 100644 (file)
@@ -183,7 +183,7 @@ class CarnetModule extends PLModule
         return Array($total, $list);
     }
 
-    function handler_contacts(&$page, $action = null, $subaction = null)
+    function handler_contacts(&$page, $action = null, $subaction = null, $ssaction = null)
     {
         $page->assign('xorg_title','Polytechnique.org - Mes contacts');
         $this->_add_rss_link($page);
@@ -228,12 +228,25 @@ class CarnetModule extends PLModule
                 }
         }
 
-        $view = new UserSet("INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid ");
+        $search = false;
+        if ($action == 'search') {
+            $action = $subaction;
+            $subaction = $ssaction;
+            $search = true;
+        }
+        if ($search && trim(Env::v('quick'))) {
+            require_once 'userset.inc.php';
+            $base = 'carnet/contacts/search';
+            $view = new SearchSet(true, false, "INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid AND ");
+        } else {
+            $base = 'carnet/contacts';
+            $view = new UserSet("INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid ");
+        }
         $view->addMod('minifiche', 'Mini-Fiches', true);
         $view->addMod('trombi', 'Trombinoscope', false, array('with_admin' => false, 'with_promo' => true));
-        $view->addMod('geoloc', 'Planisphère');
-        $view->apply('carnet/contacts', $page, $action, $subaction);
-        if ($action != 'geoloc' || !$subaction) {
+        $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'carnet/contacts/search'));
+        $view->apply($base, $page, $action, $subaction);
+        if ($action != 'geoloc' || ($search && !$ssaction) || (!$search && !$subaction)) {
             $page->changeTpl('carnet/mescontacts.tpl');
         }
     }
index 9f26a73..b4c4cca 100644 (file)
@@ -124,7 +124,7 @@ class SearchModule extends PLModule
             $view->addMod('minifiche', 'Minifiches', true, array('with_score' => true));
             if (S::logged() && !Env::i('nonins')) {
                 $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true));
-                $view->addMod('geoloc', 'Planisphère');
+                $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv'));
             }
             $view->apply('search', $page, $action, $subaction);
 
@@ -163,7 +163,7 @@ class SearchModule extends PLModule
             $view = new SearchSet(false, $action == 'geoloc' && substr($subaction, -3) == 'swf');
             $view->addMod('minifiche', 'Minifiches', true);
             $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true));
-            $view->addMod('geoloc', 'Planisphère');
+            $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv'));
             $view->apply('search/adv', $page, $action, $subaction);
             
             if ($subaction) {
index 63da70a..7664bb0 100644 (file)
@@ -78,11 +78,20 @@ else
  */
 class ThrowError
 {
+    public static $throwHook = array('ThrowError', 'defaultHandler');
+
     /** constuctor
      * @param  $explain string  the error (in natural language)
      */
     public function __construct($explain)
     {
+        call_user_func(ThrowError::$throwHook, $explain);
+    }
+
+    /** defaut error handler
+     */
+    private static function defaultHandler($explain)
+    {
         global $page, $globals;
         $page->changeTpl('search/index.tpl');
         $page->assign('xorg_title','Polytechnique.org - Annuaire');
@@ -477,8 +486,10 @@ class MapSField extends RefSField
             $this->mapId = Env::v($_fieldFormName, '');
         else
             $this->mapId = $_mapId;
+        $this->value =  $this->mapId;
         $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true, false);
     }
+    
     function get_select_statement()
     {
         if ($this->mapId === '') return false;
@@ -737,8 +748,8 @@ class SFieldGroup
     function too_large()
     {
         $b = true;
-        for ($i=0; $b && $i<count($this->fields); $i++) {
-            $b &= $this->fields[$i]->too_large();
+        for ($i=0 ; $b && $i<count($this->fields) ; $i++) {
+            $b = $b && $this->fields[$i]->too_large();
         }
         return $b;
     }
index 39e0f8b..8334c36 100644 (file)
@@ -46,7 +46,8 @@ function advancedSearchFromInput()
     $cityIdField    = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
     $countryField   = new RefSField('country',array('ap.country'),'adresses','ap',getadr_join('ap'));
     $regionField    = new RefSField('region',array('ar.region'),'adresses','ar',getadr_join('ar'));
-   
+    $mapField       = new MapSField('mapid', array('sgcim.map_id'), array('adresses','geoloc_city_in_maps'), array('amp','sgcim'), array(getadr_join('amp'), 'amp.cityid = sgcim.city_id'));
+
     $entrepriseField = new RefSField('entreprise',array('ee.entreprise'),'entreprises','ee','u.user_id=ee.uid',false);
     $posteField      = new RefSField('poste',array('ep.poste'),'entreprises','ep','u.user_id=ep.uid', false);
     $fonctionField   = new RefSField('fonction',array('en.fonction'),'entreprises','en','u.user_id=en.uid');
@@ -65,7 +66,7 @@ function advancedSearchFromInput()
     return array( 
                 $nameField, $firstnameField, $nicknameField, $promo1Field,
                 $promo2Field, $womanField, $subscriberField, $aliveField,
-                $townField, $countryField, $regionField, $entrepriseField,
+                $townField, $countryField, $regionField, $mapField, $entrepriseField,
                 $posteField, $secteurField, $cvField, $natField, $binetField,
                 $groupexField, $sectionField, $schoolField, $diplomaField,
                 $freeField, $fonctionField, $cityIdField);
index 593598c..27b11f1 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<script type="text/javascript">
+<script type="text/javascript">//<![CDATA[
 {literal}
 function ficheXorg(id)
 {
-  window.open('{/literal}{if $no_annu}https://{#globals.core.secure_domain#}/{/if}{literal}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 !$annu}https://{#globals.core.secure_domain#}/{/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}
+{if $annu}
+var search_url = platal_baseurl + "{$platal->ns}{$annu}{$plset_search|smarty:nodefaults}";
 {literal}
 function clickOnCity(id)
 {
-       var f = document.getElementById('search_form');
-       var url = f.action;
-       f.action += unescape('%26')+'cityid=' + id; 
-       f.submit();
-       f.action = url;
-       document.getElementById('search_results').style.height = '250px';
+    window.open(search_url + unescape('%26')+'cityid=' + id, '_blank', '');
 }
 var mapid = 0;
 function goToCountry(id)
 {
-       mapid = id;
+    mapid = id;
 }
-function searchMapId(f)
+function searchMapId()
 {
-       var url = f.action;
-       f.action += unescape('%26')+'mapid=' + mapid; 
-       f.submit();
-       f.action = url;
-       document.getElementById('search_results').style.height = '250px';
+    window.open(search_url + unescape('%26')+'mapid=' + mapid, '_blank', '');
 }
 {/literal}
 {/if}
 
-</script>
+//]]></script>
 
 {if !$request_geodesix}
   
@@ -93,6 +85,11 @@ function searchMapId(f)
         pluginspage="{$protocole}://www.macromedia.com/go/getflashplayer"/>
     </object>
   </p>
+  {if $annu}
+  <p class="center">
+    <a href="javascript:searchMapId()">Lister les X présents sur cette carte</a>
+  </p>
+  {/if}
   <p class="smaller">Carte fournie gracieusement par <a href="http://www.geodesix.com/">Geodesix</a>.</p>
 {else}
   <p>Le moteur de carte n'a pas été installé sur cette version de plat/al. Veuillez contacter <a href="http://www.geodesix.com/">Geodesix</a>.</p>