Merge commit 'origin/master' into fusionax
[platal.git] / include / user.func.inc.php
index c595d16..3e57923 100644 (file)
@@ -26,7 +26,7 @@
  */
 function user_clear_all_subs($user_id, $really_del=true)
 {
-    // keep datas in : aliases, adresses, tels, applis_ins, binets_ins, contacts, groupesx_ins, homonymes, identification_ax, photo
+    // keep datas in : aliases, adresses, tels, profile_education, binets_ins, contacts, groupesx_ins, homonymes, identification_ax, photo
     // delete in     : auth_user_md5, auth_user_quick, competences_ins, emails, entreprises, langues_ins, mentor,
     //                 mentor_pays, mentor_secteurs, newsletter_ins, perte_pass, requests, user_changes, virtual_redirect, watch_sub
     // + delete maillists
@@ -359,6 +359,7 @@ function get_user_details_adr($uid, $view = 'private') {
                      gp.pays AS countrytxt,a.region, a.regiontxt,
                      FIND_IN_SET('active', a.statut) AS active, a.adrid,
                      FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
+                     FIND_IN_SET('courrier', a.statut) AS courier,
                      a.pub, gp.display, a.comment
                FROM  adresses AS a
           LEFT JOIN  geoloc_pays AS gp ON (gp.a2=a.country)
@@ -403,7 +404,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
                        u.perms IN ('admin','user','disabled') AS inscrit,  FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
                        q.profile_nick AS nickname, q.profile_from_ax, q.profile_freetext AS freetext,
                        q.profile_freetext_pub AS freetext_pub,
-                       q.profile_medals_pub AS medals_pub,
+                       q.profile_medals_pub AS medals_pub, co.corps_pub AS corps_pub,
                        IF(gp1.nat='',gp1.pays,gp1.nat) AS nationalite, gp1.a2 AS iso3166_1,
                        IF(gp2.nat='',gp2.pays,gp2.nat) AS nationalite2, gp2.a2 AS iso3166_2,
                        IF(gp3.nat='',gp3.pays,gp3.nat) AS nationalite3, gp3.a2 AS iso3166_3,
@@ -416,9 +417,10 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
                        nd.display AS name_display, nd.tooltip AS name_tooltip
                  FROM  auth_user_md5   AS u
            INNER JOIN  auth_user_quick AS q   USING(user_id)
-           INNER JOIN  aliases         AS a   ON (u.user_id=a.id AND a.type='a_vie')
-           INNER JOIN  aliases         AS a2  ON (u.user_id=a2.id AND FIND_IN_SET('bestalias',a2.flags))
+           INNER JOIN  aliases         AS a   ON (u.user_id = a.id AND a.type = 'a_vie')
+           INNER JOIN  aliases         AS a2  ON (u.user_id = a2.id AND FIND_IN_SET('bestalias', a2.flags))
             LEFT JOIN  contacts        AS c   ON (c.uid = {?} and c.contact = u.user_id)
+            LEFT JOIN  profile_corps   AS co  ON (co.uid = u.user_id)
             LEFT JOIN  geoloc_pays     AS gp1 ON (gp1.a2 = u.nationalite)
             LEFT JOIN  geoloc_pays     AS gp2 ON (gp2.a2 = u.nationalite2)
             LEFT JOIN  geoloc_pays     AS gp3 ON (gp3.a2 = u.nationalite3)
@@ -492,20 +494,36 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
         $user['gpxs_join'] = join(', ', $user['gpxs']);
     }
 
-    $res = XDB::iterRow("SELECT  applis_def.text, applis_def.url, applis_ins.type
-                           FROM  applis_ins
-                     INNER JOIN  applis_def ON applis_def.id = applis_ins.aid
+    $res = XDB::iterRow("SELECT  en.name AS name, en.url AS url, d.degree AS degree,
+                                 ed.grad_year AS grad_year, f.field AS field, ed.program AS program
+                           FROM  profile_education AS ed
+                     INNER JOIN  profile_education_enum        AS en ON (en.id = ed.eduid)
+                     INNER JOIN  profile_education_degree_enum AS d  ON (d.id  = ed.degreeid)
+                     INNER JOIN  profile_education_field_enum  AS f  ON (f.id  = ed.fieldid)
                           WHERE  uid={?}
-                       ORDER BY  ordre", $uid);
-
-    $user['applis_fmt'] = Array();
-    $user['formation'] = Array();
-    while (list($txt, $url, $type) = $res->next()) {
-        $user['formation'][] = $txt." ".$type;
-        require_once('applis.func.inc.php');
-        $user['applis_fmt'][] = applis_fmt($type, $txt, $url);
+                       ORDER BY  ed.grad_year", $uid);
+
+    $user['education'] = "";
+    require_once('education.func.inc.php');
+    if (list($name, $url, $degree, $grad_year, $field, $program) = $res->next()) {
+        $user['education'] .= education_fmt($name, $url, $degree, $grad_year, $field, $program, $user['sexe'], true);
+    }
+    while (list($name, $url, $degree, $grad_year, $field, $program) = $res->next()) {
+        $user['education'] .= ", " . education_fmt($name, $url, $degree, $grad_year, $field, $program, $user['sexe'], true);
+    }
+
+    if (has_user_right($user['corps_pub'], $view)) {
+        $res = XDB::query("SELECT  e1.name AS original, e2.name AS current, r.name AS rank
+                             FROM  profile_corps           AS c
+                        LEFT JOIN  profile_corps_enum      AS e1 ON (c.original_corpsid = e1.id)
+                        LEFT JOIN  profile_corps_enum      AS e2 ON (c.current_corpsid = e2.id)
+                        LEFT JOIN  profile_corps_rank_enum AS r  ON (c.rankid = r.id)
+                            WHERE  c.uid = {?} AND c.original_corpsid != 1", $uid);
+        if ($res = $res->fetchOneRow()) {
+            list($original, $current, $rank) = $res;
+            $user['corps'] = "Corps d'origine : " . $original . ", corps actuel : " . $current . ", grade : " . $rank;
+        }
     }
-    $user['applis_join'] = join(', ', $user['applis_fmt']);
 
     if (has_user_right($user['medals_pub'], $view)) {
         $res = XDB::iterator("SELECT  m.id, m.text AS medal, m.type, s.gid, g.text AS grade
@@ -806,7 +824,7 @@ function set_user_details($uid, $details) {
         }
     }
 
-    // applis
+    // education
     // medals
 }
 // }}}