+ // AX Synchronization
+ require_once 'synchro_ax.inc.php';
+ if (is_ax_key_missing()) {
+ $page->assign('no_private_key', true);
+ }
+ if (Env::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
+ ax_synchronize(S::v('bestalias'), S::v('uid'));
+ $page->trig('Ton profil a été synchronisé avec celui du site polytechniciens.com');
+ }
+
+ // Build the page
+ $page->addJsLink('ajax.js');
+ $page->addJsLink('profile.js');
+ $page->addJsLink('applis.js');
+ $page->addJsLink('grades.js');
+ $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true);
+ require_once dirname(__FILE__) . '/profile/page.inc.php';
+ $wiz->addPage('ProfileGeneral', 'Général', 'general');
+ $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
+ $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
+ $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco');
+ $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
+ $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
+ $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
+ $wiz->apply($page, 'profile/edit', $opened_tab, $mode);
+
+ // Misc checks
+ $res = XDB::query("SELECT user_id
+ FROM auth_user_md5
+ WHERE user_id = {?} AND naissance = '0000-00-00'", S::i('uid'));
+ if ($res->numRows()) {
+ $page->trig("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
+ . " la procédure de récupération de mot de passe si un jour tu le perdais");
+ }
+
+ $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
+ }
+
+ function handler_applis_js(&$page)
+ {
+ header('Content-Type: text/javascript; charset=utf-8');
+ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+ header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
+ header('Cache-Control: no-cache, must-revalidate');
+ header('Pragma: no-cache');
+ $page->changeTpl('profile/applis.js.tpl', NO_SKIN);
+ require_once "applis.func.inc.php";
+ }
+
+ function handler_grades_js(&$page)
+ {
+ header('Content-Type: text/javascript; charset=utf-8');
+ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+ header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
+ header('Cache-Control: no-cache, must-revalidate');
+ header('Pragma: no-cache');
+ $page->changeTpl('profile/grades.js.tpl', NO_SKIN);
+ $res = XDB::iterator("SELECT *
+ FROM profile_medals_grades
+ ORDER BY mid, pos");
+ $grades = array();
+ while ($tmp = $res->next()) {
+ $grades[$tmp['mid']][] = $tmp;
+ }
+ $page->assign('grades', $grades);
+
+ $res = XDB::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
+ FROM profile_medals
+ ORDER BY type, text");
+ $mlist = array();
+ while ($tmp = $res->next()) {
+ $mlist[$tmp['type']][] = $tmp;
+ }
+ $page->assign('medal_list', $mlist);
+ }
+
+ function handler_ajax_address(&$page, $adid)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('profile/adresses.address.tpl', NO_SKIN);
+ $page->assign('i', $adid);
+ $page->assign('adr', array());
+ }
+
+ function handler_ajax_tel(&$page, $adid, $telid)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('profile/adresses.tel.tpl', NO_SKIN);
+ $page->assign('i', $adid);
+ $page->assign('adid', "addresses_$adid");
+ $page->assign('adpref', "addresses[$adid]");
+ $page->assign('t', $telid);
+ $page->assign('tel', array());
+ }
+
+ function handler_ajax_medal(&$page, $id)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('profile/deco.medal.tpl', NO_SKIN);
+ $page->assign('id', $id);
+ $page->assign('medal', array('valid' => 0, 'grade' => 0));
+ }
+
+ function handler_ajax_job(&$page, $id)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('profile/jobs.job.tpl', NO_SKIN);
+ $page->assign('i', $id);
+ $page->assign('job', array());
+ $page->assign('new', true);
+ $page->assign('secteurs', XDB::iterator("SELECT id, label
+ FROM emploi_secteur"));
+ $page->assign('fonctions', XDB::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
+ FROM fonctions_def
+ ORDER BY id"));
+ }
+
+ function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $res = XDB::iterator("SELECT id, label
+ FROM emploi_ss_secteur
+ WHERE secteur = {?}", $sect);
+ $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN);
+ $page->assign('id', $id);
+ $page->assign('ssecteurs', $res);
+ $page->assign('sel', $ssect);
+ }
+
+ function handler_ajax_skill(&$page, $cat, $id)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('profile/skill.skill.tpl', NO_SKIN);
+ $page->assign('cat', $cat);
+ $page->assign('id', $id);
+ if ($cat == 'competences') {
+ $page->assign('levels', array('initié' => 'initié',
+ 'bonne connaissance' => 'bonne connaissance',
+ 'expert' => 'expert'));
+ } else {
+ $page->assign('levels', array(1 => 'connaissance basique',
+ 2 => 'maîtrise des bases',
+ 3 => 'maîtrise limitée',
+ 4 => 'maîtrise générale',
+ 5 => 'bonne maîtrise',
+ 6 => 'maîtrise complète'));
+ }
+ }
+
+ function handler_p_orange(&$page)
+ {
+ $page->changeTpl('profile/orange.tpl');
+
+ require_once 'validations.inc.php';
+ require_once 'xorg.misc.inc.php';
+
+ $res = XDB::query(
+ "SELECT u.promo, u.promo_sortie
+ FROM auth_user_md5 AS u
+ WHERE user_id={?}", S::v('uid'));
+
+ list($promo, $promo_sortie_old) = $res->fetchOneRow();
+ $page->assign('promo_sortie_old', $promo_sortie_old);
+ $page->assign('promo', $promo);
+
+ if (!Env::has('promo_sortie')) {
+ return;
+ }
+
+ $promo_sortie = Env::i('promo_sortie');
+
+ if ($promo_sortie < 1000 || $promo_sortie > 9999) {
+ $page->trig('L\'année de sortie doit être un nombre de quatre chiffres');
+ }
+ elseif ($promo_sortie < $promo + 3) {
+ $page->trig('Trop tôt');
+ }
+ elseif ($promo_sortie == $promo_sortie_old) {
+ $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
+ }
+ elseif ($promo_sortie == $promo + 3) {
+ XDB::execute(
+ "UPDATE auth_user_md5 set promo_sortie={?}
+ WHERE user_id={?}", $promo_sortie, S::v('uid'));
+ $page->trig('Ton statut "orange" a été supprimé.');
+ $page->assign('promo_sortie_old', $promo_sortie);
+ }
+ else {
+ $page->assign('promo_sortie', $promo_sortie);
+
+ if (Env::has('submit')) {
+ $myorange = new OrangeReq(S::v('uid'),
+ $promo_sortie);
+ $myorange->submit();
+ $page->assign('myorange', $myorange);
+ }
+ }
+ }
+
+ function handler_referent(&$page, $x = null)
+ {
+ require_once 'user.func.inc.php';
+
+ if (is_null($x)) {
+ return PL_NOT_FOUND;
+ }
+
+ $page->changeTpl('profile/fiche_referent.tpl', SIMPLE);
+
+ $res = XDB::query(
+ "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
+ FROM auth_user_md5 AS u
+ INNER JOIN aliases AS a ON (u.user_id=a.id
+ AND FIND_IN_SET('bestalias', a.flags))
+ INNER JOIN aliases AS a1 ON (u.user_id=a1.id
+ AND a1.alias = {?}
+ AND a1.type!='homonyme')", $x);
+
+ if ($res->numRows() != 1) {
+ return PL_NOT_FOUND;
+ }
+
+ list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
+
+ $page->assign('prenom', $prenom);
+ $page->assign('nom', $nom);
+ $page->assign('promo', $promo);
+ $page->assign('cv', MiniWiki::WikiToHTML($cv, true));
+ $page->assign('bestalias', $bestalias);
+ $page->assign('adr_pro', get_user_details_pro($user_id));
+
+ ///// recuperations infos referent
+
+ //expertise
+ $res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
+ $page->assign('expertise', $res->fetchOneCell());
+
+ //secteurs
+ $secteurs = $ss_secteurs = Array();
+ $res = XDB::iterRow(
+ "SELECT s.label, ss.label
+ FROM mentor_secteurs AS m
+ LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
+ LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
+ WHERE uid = {?}", $user_id);
+ while (list($sec, $ssec) = $res->next()) {
+ $secteurs[] = $sec;
+ $ss_secteurs[] = $ssec;
+ }
+ $page->assign_by_ref('secteurs', $secteurs);
+ $page->assign_by_ref('ss_secteurs', $ss_secteurs);
+
+ //pays
+ $res = XDB::query(
+ "SELECT gp.pays
+ FROM mentor_pays AS m
+ LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
+ WHERE uid = {?}", $user_id);
+ $page->assign('pays', $res->fetchColumn());
+
+ $page->addJsLink('close_on_esc.js');
+ }
+
+ function handler_ref_search(&$page, $action = null, $subaction = null)
+ {
+ require_once 'wiki.inc.php';
+ wiki_require_page('Docs.Emploi');
+ $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
+
+ //recuperation des noms de secteurs
+ $res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
+ $secteurs[''] = '';
+ while (list($tmp_id, $tmp_label) = $res->next()) {
+ $secteurs[$tmp_id] = $tmp_label;
+ }
+ $page->assign_by_ref('secteurs', $secteurs);
+
+ // nb de mentors
+ $res = XDB::query("SELECT count(*) FROM mentor");
+ $page->assign('mentors_number', $res->fetchOneCell());
+
+ // On vient d'un formulaire
+ $where = array();
+ $pays_sel = XDB::escape(Env::v('pays_sel'));
+ $secteur_sel = XDB::escape(Env::v('secteur'));
+ $ss_secteur_sel = XDB::escape(Env::v('ss_secteur'));
+ $expertise_champ = XDB::escape(Env::v('expertise'));
+
+ if ($pays_sel != "''") {
+ $where[] = "mp.pid = $pays_sel";
+ }
+ if ($secteur_sel != "''") {
+ $where[] = "ms.secteur = $secteur_sel";
+ if ($ss_secteur_sel != "''") {
+ $where[] = "ms.ss_secteur = $ss_secteur_sel";
+ }
+ }
+ if ($expertise_champ != "''") {
+ $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
+ }
+
+ if ($where) {
+ $where = join(' AND ', $where);
+
+ $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
+ LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
+ LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
+ $where);
+ $set->addMod('mentor', 'Référents');
+ $set->apply('referent/search', $page, $action, $subaction);
+ if ($set->count() > 100) {
+ $page->assign('recherche_trop_large', true);
+ }
+ }
+ $page->changeTpl('profile/referent.tpl');
+ }
+
+ function handler_ref_sect(&$page, $sect)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('include/field.select.tpl', NO_SKIN);
+ $page->assign('onchange', 'setSSecteurs()');
+ $page->assign('id', 'ssect_field');
+ $page->assign('name', 'ss_secteur');
+ $it = XDB::iterator("SELECT id,label AS field
+ FROM emploi_ss_secteur
+ WHERE secteur = {?}", $sect);
+ $page->assign('list', $it);
+ }
+
+ function handler_ref_country(&$page, $sect, $ssect = '')
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('include/field.select.tpl', NO_SKIN);
+ $page->assign('name', 'pays_sel');
+ $where = ($ssect ? ' AND ms.ss_secteur = {?}' : '');
+ $it = XDB::iterator("SELECT a2 AS id, pays AS field
+ FROM geoloc_pays AS g
+ INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
+ INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
+ WHERE ms.secteur = {?} $where
+ GROUP BY a2
+ ORDER BY pays", $sect, $ssect);
+ $page->assign('list', $it);
+ }
+
+ function handler_p_usage(&$page)
+ {
+ $page->changeTpl('profile/nomusage.tpl');