Displays search results on maps for all users (not connected, ax, x).
authorStéphane Jacob <sj@m4x.org>
Sun, 12 Jun 2011 16:50:26 +0000 (18:50 +0200)
committerStéphane Jacob <sj@m4x.org>
Sun, 12 Jun 2011 16:50:26 +0000 (18:50 +0200)
The addresses displayed correspond to the publicity the user is enabled
to, ie ax secretaries will only see ax addresses and not loggued users
will only see public addresses.

Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/geoloc.php
modules/search.php

index 5e58052..340dfd4 100644 (file)
@@ -49,9 +49,19 @@ class GeolocModule extends PLModule
             $where = '';
         }
 
+        if (!S::logged() || !S::user()->checkPerms('directory_ax')) {
+            $where .= " AND pa.pub = 'public'";
+            $name_publicity = 'public';
+        } else if (!S::user()->checkPerms('directory_private')) {
+            $where .= " AND pa.pub = 'ax'";
+            $name_publicity = 'public';
+        } else {
+            $name_publicity = 'private';
+        }
+
         $data = XDB::rawFetchAllAssoc('SELECT  pa.latitude, pa.longitude, GROUP_CONCAT(DISTINCT p.hrpid SEPARATOR \',\') AS hrpid,
                                                GROUP_CONCAT(pd.promo SEPARATOR \',\') AS promo,
-                                               GROUP_CONCAT(DISTINCT pd.private_name, \' (\', pd.promo, \')\' SEPARATOR \', \') AS name,
+                                               GROUP_CONCAT(DISTINCT pd.' . $name_publicity . '_name, \' (\', pd.promo, \')\' SEPARATOR \', \') AS name,
                                                GROUP_CONCAT(DISTINCT pa.pid SEPARATOR \',\') AS pid
                                          FROM  profile_addresses AS pa
                                    INNER JOIN  profiles          AS p  ON (pa.pid = p.pid)
index d3c9164..237c739 100644 (file)
@@ -121,9 +121,9 @@ class SearchModule extends PLModule
             require_once 'userset.inc.php';
             $view = new QuickSearchSet();
             $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true, 'starts_with' => $byletter));
+            $view->addMod('map', 'Planisphère');
             if (S::logged() && !Env::i('nonins')) {
                 $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true));
-                $view->addMod('map', 'Planisphère');
             }
             $view->apply('search', $page, $model);