git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-90
require_once("xorg.inc.php");
new_simple_page('fiche.tpl',AUTH_COOKIE);
-
-require_once('applis.func.inc.php');
require_once('user.func.inc.php');
//$isnetscape = !empty($_SESSION['skin_compatible']);
}
$new = (isset($_REQUEST["modif"]) && $_REQUEST["modif"]=="new");
-
-$reqsql = "SELECT u.prenom, u.nom, u.epouse,
- IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166,
- u.user_id, a.alias AS forlife, a2.alias AS bestalias,
- u.matricule, u.perms IN ('admin','user') AS inscrit,
- FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
- u.date, u.cv, sections.text AS section, u.mobile, u.web,
- u.libre, u.promo, c.uid IS NOT NULL AS is_contact, p.x, p.y,
-
- m.expertise != '' AS is_referent
-
- FROM auth_user_md5 AS u
- 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 = {$_SESSION['uid']} and c.contact = u.user_id)
- LEFT JOIN geoloc_pays AS gp ON (gp.a2 = u.nationalite)
- INNER JOIN sections ON (sections.id = u.section)
- LEFT JOIN photo AS p ON (p.uid = u.user_id)
- LEFT JOIN mentor AS m ON (m.uid = u.user_id)
- WHERE a.alias = '$login'";
-
-$result = $globals->db->query($reqsql);
-$user = mysql_fetch_assoc($result);
-mysql_free_result($result);
+$user = get_user_details($login, $_SESSION['uid']);
$title = $user['prenom'] . ' ' . empty($user['epouse']) ? $user['nom'] : $user['epouse'];
$page->assign('xorg_title', $title);
$page->assign('photo_url', $photo);
$page->assign_by_ref('x', $user);
-//recuperation des infos professionnelles
-$sql = "SELECT e.entreprise, s.label as secteur , ss.label as sous_secteur , f.fonction_fr as fonction,
- e.poste, e.adr1, e.adr2, e.adr3, e.cp, e.ville,
- gp.pays, gr.name, e.tel, e.fax
- FROM entreprises AS e
- LEFT JOIN emploi_secteur AS s ON(e.secteur = s.id)
- LEFT JOIN emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur)
- LEFT JOIN fonctions_def AS f ON(e.fonction = f.id)
- LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.pays)
- LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.pays and gr.region = e.region)
- WHERE e.uid = {$user['user_id']}
- ORDER BY e.entrid";
-$page->mysql_assign($sql, 'adr_pro');
-
-//recuperation des adresses
-$sql = "SELECT a.adr1,a.adr2,a.adr3,a.cp,a.ville,
- gp.pays,gr.name AS region,a.tel,a.fax,
- FIND_IN_SET('active', a.statut) AS active,
- FIND_IN_SET('res-secondaire', a.statut) AS secondaire
- FROM adresses AS a
- LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.pays)
- LEFT JOIN geoloc_region AS gr ON (gr.a2=a.pays and gr.region=a.region)
- WHERE uid={$user['user_id']} AND NOT FIND_IN_SET('pro',a.statut)
- ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)";
-$page->mysql_assign($sql, 'adr');
-
-// reformatage binets
-$sql = "SELECT text
- FROM binets_ins
- LEFT JOIN binets_def ON binets_ins.binet_id = binets_def.id
- WHERE user_id = {$user['user_id']}";
-$res = $globals->db->query($sql);
-if (list($binets) = mysql_fetch_row($res)){
- while (list($binet) = mysql_fetch_row($res)) {
- $binets .= ", $binet";
- }
-}
-mysql_free_result($res);
-$page->assign('binets', $binets);
-
-// reformatage Groupes X
-$res = $globals->db->query("SELECT text, url
- FROM groupesx_ins
- LEFT JOIN groupesx_def ON groupesx_ins.gid = groupesx_def.id
- WHERE guid = '{$user['user_id']}'");
-$gxs = Array();
-while (list($gxt,$gxu) = mysql_fetch_row($res)) {
- if ($gxu) {
- $gxs[] = "<a href=\"$gxu\" onclick=\"return popup(this)\">$gxt</a>";
- } else {
- $gxs[] = $gxt;
- }
-}
-mysql_free_result($res);
-$page->assign('groupes', join(', ', $gxs));
-
-// reformatage appli
-$res = $globals->db->query("SELECT applis_def.text, applis_def.url, applis_ins.type
- FROM applis_ins
- INNER JOIN applis_def ON applis_def.id = applis_ins.aid
- WHERE uid='{$user['user_id']}'
- ORDER BY ordre");
-if (list($rapp_txt, $rapp_url, $rapp_type) = mysql_fetch_row($res)) {
- $applis = applis_fmt($rapp_type, $rapp_txt, $rapp_url);
- while (list($rapp_txt, $rapp_url, $rapp_type) = mysql_fetch_row($res)) {
- $applis .=", ";
- $applis .= applis_fmt($rapp_type, $rapp_txt, $rapp_url);
- }
- $page->assign('applis', $applis);
-}
-mysql_free_result($res);
-
$page->run();
?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
+global $page;
function applis_options($current=0) {
global $globals;
}
// }}}
+// {{{ function get_user_details()
+function &get_user_details($login, $from_uid)
+{
+ global $globals;
+ $reqsql = "SELECT u.prenom, u.nom, u.epouse,
+ IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166,
+ u.user_id, a.alias AS forlife, a2.alias AS bestalias,
+ u.matricule, u.perms IN ('admin','user') AS inscrit,
+ FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
+ u.date, u.cv, sections.text AS section, u.mobile, u.web,
+ u.libre, u.promo, c.uid IS NOT NULL AS is_contact, p.x, p.y,
+
+ m.expertise != '' AS is_referent
+
+ FROM auth_user_md5 AS u
+ 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 = '$from_uid' and c.contact = u.user_id)
+ LEFT JOIN geoloc_pays AS gp ON (gp.a2 = u.nationalite)
+ INNER JOIN sections ON (sections.id = u.section)
+ LEFT JOIN photo AS p ON (p.uid = u.user_id)
+ LEFT JOIN mentor AS m ON (m.uid = u.user_id)
+ WHERE a.alias = '$login'";
+
+ $res = $globals->db->query($reqsql);
+ $user = mysql_fetch_assoc($res);
+ mysql_free_result($res);
+
+ $uid = $user['user_id'];
+
+ $sql = "SELECT e.entreprise, s.label as secteur , ss.label as sous_secteur , f.fonction_fr as fonction,
+ e.poste, e.adr1, e.adr2, e.adr3, e.cp, e.ville,
+ gp.pays, gr.name, e.tel, e.fax
+ FROM entreprises AS e
+ LEFT JOIN emploi_secteur AS s ON(e.secteur = s.id)
+ LEFT JOIN emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur)
+ LEFT JOIN fonctions_def AS f ON(e.fonction = f.id)
+ LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.pays)
+ LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.pays and gr.region = e.region)
+ WHERE e.uid = $uid
+ ORDER BY e.entrid";
+ $res = $globals->db->query($sql);
+ while($tmp = mysql_fetch_assoc($res)) {
+ $user['adr_pro'][] = $tmp;
+ }
+ mysql_free_result($res);
+
+ $sql = "SELECT a.adr1,a.adr2,a.adr3,a.cp,a.ville,
+ gp.pays,gr.name AS region,a.tel,a.fax,
+ FIND_IN_SET('active', a.statut) AS active,
+ FIND_IN_SET('res-secondaire', a.statut) AS secondaire
+ FROM adresses AS a
+ LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.pays)
+ LEFT JOIN geoloc_region AS gr ON (gr.a2=a.pays and gr.region=a.region)
+ WHERE uid={$user['user_id']} AND NOT FIND_IN_SET('pro',a.statut)
+ ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)";
+ $res = $globals->db->query($sql);
+ while($tmp = mysql_fetch_assoc($res)) {
+ $user['adr'][] = $tmp;
+ }
+ mysql_free_result($res);
+
+
+ $sql = "SELECT text
+ FROM binets_ins
+ LEFT JOIN binets_def ON binets_ins.binet_id = binets_def.id
+ WHERE user_id = {$user['user_id']}";
+ $res = $globals->db->query($sql);
+ while (list($binet) = mysql_fetch_row($res)) {
+ $user['binets'][] = $binet;
+ }
+ if (mysql_num_rows($res)) {
+ $user['binets_join'] = join(', ', $user['binets']);
+ }
+ mysql_free_result($res);
+
+ $res = $globals->db->query("SELECT text, url
+ FROM groupesx_ins
+ LEFT JOIN groupesx_def ON groupesx_ins.gid = groupesx_def.id
+ WHERE guid = '{$user['user_id']}'");
+ while (list($gxt,$gxu) = mysql_fetch_row($res)) {
+ if ($gxu) {
+ $user['gpxs'][] = "<a href=\"$gxu\">$gxt</a>";
+ } else {
+ $user['gpxs'][] = $gxt;
+ }
+ }
+ if (mysql_num_rows($res)) {
+ $user['gpxs_join'] = join(', ', $user['gpxs']);
+ }
+ mysql_free_result($res);
+
+ $res = $globals->db->query("SELECT applis_def.text, applis_def.url, applis_ins.type
+ FROM applis_ins
+ INNER JOIN applis_def ON applis_def.id = applis_ins.aid
+ WHERE uid='{$user['user_id']}'
+ ORDER BY ordre");
+
+ while (list($type, $txt, $url) = mysql_fetch_assoc($res)) {
+ require_once('applis.func.inc.php');
+ $user['applis_fmt'][] = applis_fmt($type, $txt, $url);
+ }
+ if (mysql_num_rows($res)) {
+ $user['applis_join'] = join(', ', $user['applis_fmt']);
+ }
+ mysql_free_result($res);
+
+ return $user;
+}
+
+// }}}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
{if $x.iso3166}
<img src='{rel}/images/flags/{$x.iso3166}.gif' alt='{$x.nationalite}' height='14' title='{$x.nationalite}' />
{/if}
- X {$x.promo}{if $applis} - Formation : {$applis|smarty:nodefaults}{/if}
+ X {$x.promo}{if $x.applis_join} - Formation : {$x.applis_join|smarty:nodefaults}{/if}
{if $x.is_referent}
[<a href="fiche_referent.php?user={$x.forlife}" class='popup'>Ma fiche référent</a>]
{/if}
<td rowspan="4" id='photo'>
<img alt="Photo de {$x.forlife}" src="{$photo_url}" width="{$x.x}" height="{$x.y}" />
{if $x.section}<em class="intitule">Section : </em><span>{$x.section}</span><br />{/if}
- {if $binets}<em class="intitule">Binet(s) : </em><span>{$binets}</span><br />{/if}
- {if $groupes}<em class="intitule">Groupe(s) X : </em><span>{$groupes|smarty:nodefaults}</span><br />{/if}
+ {if $x.binets_join}<em class="intitule">Binet(s) : </em><span>{$x.binets_join}</span><br />{/if}
+ {if $x.gpxs_join}<em class="intitule">Groupe(s) X : </em><span>{$x.gpxs_join|smarty:nodefaults}</span><br />{/if}
{if $x.web}<em class="intitule">Site Web : </em><a href="{$x.web}" class='popup'>{$x.web}</a>{/if}
{if $x.libre}<br /><em class="intitule">Commentaires : </em><br /><span>{$x.libre|nl2br}</span>{/if}
</td>
</tr>
- {if $adr|@count > 0}
+ {if $x.adr}
<tr>
<td>
<h2>Contact : </h2>
- {foreach from=$adr item="address" key="i"}
+ {foreach from=$x.adr item="address" key="i"}
<div class="adresse">
<div class="titre">
{if $address.active}
</td>
</tr>
{/if}
- {if $adr_pro|@count > 0}
+ {if $x.adr_pro}
<tr>
<td>
<h2>Informations professionnelles :</h2>
- {foreach from=$adr_pro item="address" key="i"}
+ {foreach from=$x.adr_pro item="address" key="i"}
<div class="adresse">
{if $address.entreprise}
<div>