Merge commit 'origin/fusionax' into account
[platal.git] / modules / profile / jobs.inc.php
index e392d46..cafc7c6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class ProfileJob extends ProfileGeoloc
+class ProfileJob extends ProfileGeocoding
 {
     private $pub;
     private $mail_new;
@@ -131,7 +131,7 @@ class ProfileJob extends ProfileGeoloc
         }
         foreach ($value as $key=>&$job) {
             $ls = true;
-            $this->geolocAddress($job['w_adr'], $s);
+            $this->geocodeAddress($job['w_adr'], $s);
             $ls = ($ls && $s);
             $this->cleanJob($page, $key, $job, $s);
             $ls = ($ls && $s);
@@ -193,9 +193,9 @@ class ProfileJobs extends ProfilePage
     {
         // Checkout the CV
         $res = XDB::query("SELECT  cv
-                             FROM  auth_user_md5
-                            WHERE  user_id = {?}",
-                          S::i('uid'));
+                             FROM  profiles
+                            WHERE  pid = {?}",
+                          $this->pid());
         $this->values['cv'] = $res->fetchOneCell();
 
         // Checkout the corps
@@ -203,30 +203,29 @@ class ProfileJobs extends ProfilePage
                                    rankid AS rank, corps_pub AS pub
                              FROM  profile_corps
                             WHERE  uid = {?}",
-                          S::i('uid'));
+                        $this->pid());
         $this->values['corps'] = $res->fetchOneAssoc();
 
         // Build the jobs tree
         $res = XDB::iterRow("SELECT  j.id, je.name, j.functionid, j.sectorid, j.subsectorid,
                                      j.subsubsectorid, j.description, e.adr1, e.adr2, e.adr3,
                                      e.postcode, e.city, e.cityid, e.region, e.regiontxt,
-                                     e.country, gp.pays, gp.display,
-                                     FIND_IN_SET('geoloc', flags),
+                                     e.country, gc.countryFR,
                                      j.email, j.url, j.pub,
                                      e.adr_pub, j.email_pub,
                                      e.glat, e.glng, s.name
                                FROM  profile_job                   AS j
                           LEFT JOIN  profile_job_enum              AS je ON (j.jobid = je.id)
                           LEFT JOIN  entreprises                   AS e  ON (j.uid = e.uid AND j.id = e.entrid)
-                          LEFT JOIN  geoloc_pays                   AS gp ON (gp.a2 = e.country)
+                          LEFT JOIN  geoloc_countries              AS gc ON (gc.iso_3166_1_a2 = e.country)
                           LEFT JOIN  profile_job_subsubsector_enum AS s  ON (s.id = j.subsubsectorid)
                               WHERE  j.uid = {?}
-                           ORDER BY  entrid", S::i('uid'));
+                           ORDER BY  entrid", $this->pid());
         $this->values['jobs'] = array();
         while (list($id, $name, $function, $secteur, $ss_secteur, $sss_secteur, $description,
                     $w_adr1, $w_adr2, $w_adr3, $w_postcode, $w_city, $w_cityid,
-                    $w_region, $w_regiontxt, $w_country, $w_countrytxt, $w_display,
-                    $w_checked, $w_email, $w_web,
+                    $w_region, $w_regiontxt, $w_country, $w_countrytxt,
+                    $w_email, $w_web,
                     $pub, $w_adr_pub, $w_email_pub, $w_glat, $w_glng, $sss_secteur_name
                    ) = $res->next()) {
             $this->values['jobs'][] = array('id'               => $id,
@@ -247,9 +246,8 @@ class ProfileJobs extends ProfilePage
                                                                         'regiontxt'   => $w_regiontxt,
                                                                         'country'     => $w_country,
                                                                         'countrytxt'  => $w_countrytxt,
-                                                                        'display'     => $w_display,
                                                                         'pub'         => $w_adr_pub,
-                                                                        'checked'     => $w_checked,
+                                                                        'checked'     => (($w_checked == 0)? true : false),
                                                                         'precise_lat' => $w_glat,
                                                                         'precise_lon' => $w_glng),
                                             'w_email'          => $w_email,
@@ -262,7 +260,7 @@ class ProfileJobs extends ProfilePage
                                 FROM  profile_phones
                                WHERE  uid = {?} AND link_type = 'pro'
                             ORDER BY  link_id",
-                             S::i('uid'));
+                             $this->pid());
         $i = 0;
         $jobNb = count($this->values['jobs']);
         while ($tel = $res->next()) {
@@ -293,10 +291,10 @@ class ProfileJobs extends ProfilePage
     protected function _saveData()
     {
         if ($this->changed['cv']) {
-            XDB::execute("UPDATE  auth_user_md5
+            XDB::execute("UPDATE  profiles
                              SET  cv = {?}
-                           WHERE  user_id = {?}",
-                         $this->values['cv'], S::i('uid'));
+                           WHERE  pid = {?}",
+                         $this->values['cv'], $this->pid());
         }
 
         if ($this->changed['corps']) {
@@ -305,14 +303,14 @@ class ProfileJobs extends ProfilePage
                                   rankid = {?}, corps_pub = {?}
                            WHERE  uid = {?}",
                           $this->values['corps']['original'], $this->values['corps']['current'],
-                          $this->values['corps']['rank'], $this->values['corps']['pub'], S::i('uid'));
+                          $this->values['corps']['rank'], $this->values['corps']['pub'], $this->pid());
         }
     }
 
     public function _prepare(PlPage &$page, $id)
     {
         require_once "emails.combobox.inc.php";
-        fill_email_combobox($page);
+        fill_email_combobox($page, $this->owner, $this->profile);
 
         $res = XDB::query("SELECT  id, name AS label
                              FROM  profile_job_sector_enum");