Finishes to move functions from geoloc.inc.php to geocoding.inc.php,
[platal.git] / include / userset.inc.php
index 01bbcfb..be9e740 100644 (file)
@@ -33,10 +33,10 @@ global $globals;
     LEFT JOIN  geoloc_pays             AS n1  ON (u.nationalite = n1.a2)
     LEFT JOIN  geoloc_pays             AS n2  ON (u.nationalite2 = n2.a2)
     LEFT JOIN  geoloc_pays             AS n3  ON (u.nationalite2 = n3.a2)
-    LEFT JOIN  adresses                AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
-    LEFT JOIN  geoloc_pays             AS gp  ON (adr.country = gp.a2)
-    LEFT JOIN  geoloc_region           AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)
-    LEFT JOIN  emails                  AS em  ON (em.uid = u.user_id AND em.flags = \'active\')';
+    LEFT JOIN  profile_addresses       AS adr ON (u.user_id = adr.pid AND FIND_IN_SET(\'current\', adr.flags))
+    LEFT JOIN  geoloc_countries        AS gc  ON (adr.countryId = gc.iso_3166_1_a2)
+    '//LEFT JOIN  geoloc_region           AS gr  ON (adr.countryId = gr.a2 AND adr.region = gr.region)
+  . 'LEFT JOIN  emails                  AS em  ON (em.uid = u.user_id AND em.flags = \'active\')';
 
 class UserSet extends PlSet
 {
@@ -194,7 +194,8 @@ class MinificheView extends MultipageView
                 IF(ede3.abbreviation = '', ede3.name, ede3.abbreviation) AS eduname3, ede3.url AS eduurl3,
                 IF(edd3.abbreviation = '', edd3.degree, edd3.abbreviation) AS edudegree3,
                 edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3,
-                adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
+                "// adr.localityId, gr.name AS region
+              . "gc.iso_3166_1_a2, gc.countryFR AS countrytxt
                 (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif,
                 d.directory_name, d.sort_name" .
                 (S::logged() ? ", c.contact AS contact" : '');
@@ -227,12 +228,13 @@ class MinificheView extends MultipageView
                  LEFT JOIN  profile_education_enum        AS ede3 ON (ede3.id = edu3.eduid)
                  LEFT JOIN  profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid)
                  LEFT JOIN  profile_education_field_enum  AS f3   ON (f3.id = edu3.fieldid)
-                 LEFT JOIN  adresses                      AS adr  ON (u.user_id = adr.uid
-                                                                      AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : "
-                                                                      AND adr.pub = 'public'").")
-                 LEFT JOIN  geoloc_pays                   AS gp   ON (adr.country = gp.a2)
-                 LEFT JOIN  geoloc_region                 AS gr   ON (adr.country = gr.a2 AND adr.region = gr.region)
-                 LEFT JOIN  emails                        AS em   ON (em.uid = u.user_id AND em.flags = 'active')
+                 LEFT JOIN  profile_addresses             AS adr  ON (u.user_id = adr.pid
+                                                                      AND FIND_IN_SET('current', adr.flags)"
+                                                                      . (S::logged() ? "" :
+                                                                         "AND adr.pub = 'public'") . ")
+                 LEFT JOIN  geoloc_countries              AS gc   ON (adr.countryId = gc.iso_3166_a2)
+                 " // LEFT JOIN  geoloc_region                 AS gr   ON (adr.country = gr.a2 AND adr.region = gr.region)
+              . "LEFT JOIN  emails                        AS em   ON (em.uid = u.user_id AND em.flags = 'active')
                 INNER JOIN  profile_display               AS d    ON (d.pid = u.user_id)" . (S::logged() ?
                 "LEFT JOIN  contacts                      AS c    ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
                  : "");
@@ -365,102 +367,6 @@ class TrombiView extends MultipageView
     }
 }
 
-class GeolocView implements PlView
-{
-    private $set;
-    private $type;
-    private $params;
-
-    public function __construct(PlSet &$set, $data, array $params)
-    {
-        $this->params = $params;
-        $this->set   =& $set;
-        $this->type   = $data;
-    }
-
-    private function use_map()
-    {
-        return is_file(dirname(__FILE__) . '/../modules/geoloc/dynamap.swf') &&
-               is_file(dirname(__FILE__) . '/../modules/geoloc/icon.swf');
-    }
-
-    public function args()
-    {
-        $args = $this->set->args();
-        unset($args['initfile']);
-        unset($args['mapid']);
-        return $args;
-    }
-
-    public function apply(PlPage &$page)
-    {
-        require_once 'geoloc.inc.php';
-        require_once '../modules/search/search.inc.php';
-
-        switch ($this->type) {
-          case 'icon.swf':
-            header("Content-type: application/x-shockwave-flash");
-            header("Pragma:");
-            readfile(dirname(__FILE__).'/../modules/geoloc/icon.swf');
-            exit;
-
-          case 'dynamap.swf':
-            header("Content-type: application/x-shockwave-flash");
-            header("Pragma:");
-            readfile(dirname(__FILE__).'/../modules/geoloc/dynamap.swf');
-            exit;
-
-          case 'init':
-            $page->changeTpl('geoloc/init.tpl', NO_SKIN);
-            header('Content-Type: text/xml');
-            header('Pragma:');
-            if (!empty($GLOBALS['IS_XNET_SITE'])) {
-                $page->assign('background', 0xF2E9D0);
-            }
-            break;
-
-          case 'city':
-            $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, d.promo, al.alias',
-                                   "INNER JOIN  adresses        AS adrf ON (adrf.uid = u.user_id $only_current)
-                                    INNER JOIN  profile_display AS d    ON (d.pid = u.user_id)
-                                     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') . ")",
-                                   'adrf.cityid = ' . Env::i('cityid'), null, null, 11);
-            $page->assign('users', $it);
-            break;
-
-          case 'country':
-            if (Env::has('debug')) {
-                $page->changeTpl('geoloc/country.tpl', SIMPLE);
-            } else {
-                $page->changeTpl('geoloc/country.tpl', NO_SKIN);
-                header('Content-Type: text/xml');
-                header('Pragma:');
-            }
-            $mapid = Env::has('mapid') ? Env::i('mapid', -2) : false;
-            list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set, 10);
-            $page->assign('countries', $countries);
-            $page->assign('cities', $cities);
-            break;
-
-          default:
-            global $globals;
-            if (!$this->use_map()) {
-                $page->assign('request_geodesix', 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';
-        }
-    }
-}
-
 class GadgetView implements PlView
 {
     public function __construct(PlSet &$set, $data, array $params)
@@ -475,18 +381,20 @@ class GadgetView implements PlView
                 u.perms != 'pending' AS wasinscrit,
                 u.deces != 0 AS dcd, u.deces,
                 FIND_IN_SET('femme', u.flags) AS sexe,
-                adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
+                " // adr.city, gr.name AS region
+              . "gc.iso_3166_1_a2, gc.countryFR AS countrytxt" .
                 (S::logged() ? ", c.contact AS contact" : '');
     }
 
     public function joins()
     {
-        return  "LEFT JOIN  adresses      AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : "
-                                                                         AND adr.pub = 'public'").")
-                 LEFT JOIN  geoloc_pays   AS gp  ON (adr.country = gp.a2)
-                 LEFT JOIN  geoloc_region AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)" .
-                (S::logged() ?
-                "LEFT JOIN  contacts      AS c   ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
+        return  "LEFT JOIN  profile_addresses AS adr ON (u.user_id = adr.pid AND
+                                                         FIND_IN_SET('current', adr.flags)"
+                                                         . (S::logged() ? "" : "AND adr.pub = 'public'") . ")
+                 LEFT JOIN  geoloc_countries     AS gc  ON (adr.countryId = gc.iso_3166_1_a2)"
+                 // LEFT JOIN  geoloc_region     AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)
+                 . (S::logged() ?
+                "LEFT JOIN  contacts          AS c   ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
                  : "");
     }