'profile/networking' => $this->make_hook('networking', AUTH_PUBLIC),
'profile/ajax/job' => $this->make_hook('ajax_job', AUTH_COOKIE, 'user', NO_AUTH),
'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH),
+ 'profile/ajax/ssecteur' => $this->make_hook('ajax_ssecteur', AUTH_COOKIE, 'user', NO_AUTH),
'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE, 'user', NO_AUTH),
'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE, 'user', NO_AUTH),
'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE),
return PL_NOT_FOUND;
}
- $login = S::logged() ? User::get($x) : User::getSilent($x);
+ $login = (!is_numeric($x) || S::has_perms()) ? Profile::get($x) : null;
if (!$login) {
+ if (S::logged()) {
+ $page->trigError($x . ' inconnu dans l\'annuaire');
+ }
return PL_NOT_FOUND;
}
WHERE user_id = {?}", $login->id());
if ($res->fetchOneCell()) {
$new = Env::v('modif') == 'new';
- $user = get_user_details($login->login(), S::v('uid'), $view);
+ $user = get_user_details($login->hrid(), S::v('uid'), $view);
} else {
$new = false;
$user = array();
if (S::logged()) {
- pl_redirect('marketing/public/' . $login->login());
+ pl_redirect('marketing/public/' . $login->hrid());
}
}
// Profile view are logged.
if (S::logged()) {
- S::logger()->log('view_profile', $login->login());
+ S::logger()->log('view_profile', $login->hrid());
}
// Sets the title of the html page.
$page->setTitle($login->fullName());
// Prepares the display of the user's mugshot.
- $photo = 'photo/' . $login->login() . ($new ? '/req' : '');
+ $photo = 'photo/' . $login->hrid() . ($new ? '/req' : '');
if (!isset($user['photo_pub']) || !has_user_right($user['photo_pub'], $view)) {
$photo = "";
}
// Determines and displays the virtual alias.
global $globals;
- $res = XDB::query(
- "SELECT alias
- FROM virtual
- INNER JOIN virtual_redirect USING (vid)
- INNER JOIN auth_user_quick ON (user_id = {?} AND emails_alias_pub = 'public')
- WHERE (redirect={?} OR redirect={?})
- AND alias LIKE '%@{$globals->mail->alias_dom}'",
- $login->id(),
- $login->forlifeEmail(),
- // TODO(vzanotti): get ride of all @m4x.org addresses in the
- // virtual redirect base, and remove this über-ugly hack.
- $login->login() . '@' . $globals->mail->domain2);
- $page->assign('virtualalias', $res->fetchOneCell());
+ $owner = $login->owner();
+ if ($owner) {
+ $page->assign('virtualalias', $owner->emailAlias());
+ }
// Adds miscellaneous properties to the display.
// Adds the global user property array to the display.
$page->assign_by_ref('x', $user);
- $page->assign_by_ref('user', $login);
+ $page->assign_by_ref('user', $owner);
$page->assign('logged', has_user_right('private', $view));
$page->assign('view', $view);
http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
}
- function handler_p_edit(&$page, $opened_tab = null, $mode = null)
+ function handler_p_edit(&$page, $user = null, $opened_tab = null, $mode = null)
{
global $globals;
+ if (is_null($user)) {
+ $user = S::user();
+ if (!$user->hasProfile()) {
+ return PL_NOT_FOUND;
+ } else {
+ pl_redirect('profile/edit/' . $user->profile()->hrid());
+ }
+ } else {
+ $user = Profile::get($user);
+ if (!$user) {
+ return PL_NOT_FOUND;
+ } else if (!S::user()->canEdit($user) && Platal::notAllowed()) {
+ return PL_FORBIDDEN;
+ }
+ }
+
// AX Synchronization
require_once 'synchro_ax.inc.php';
if (is_ax_key_missing()) {
$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);
+ $wiz->apply($page, 'profile/edit/' . $user->hrid(), $opened_tab, $mode);
// Misc checks
$res = XDB::query("SELECT user_id
$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)
+ $res = XDB::query("SELECT id, name AS label
+ FROM profile_job_sector_enum");
+ $page->assign('secteurs', $res->fetchAllAssoc());
+ $res = XDB::query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
+ FROM fonctions_def
+ ORDER BY id");
+ $page->assign('fonctions', $res->fetchAllAssoc());
+ require_once "emails.combobox.inc.php";
+ fill_email_combobox($page);
+ }
+
+ function handler_ajax_secteur(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1)
{
header('Content-Type: text/html; charset=utf-8');
- $res = XDB::iterator("SELECT id, label
- FROM emploi_ss_secteur
- WHERE secteur = {?}", $sect);
+ $res = XDB::iterator("SELECT id, name AS label, FIND_IN_SET('optgroup', flags) AS optgroup
+ FROM profile_job_subsector_enum
+ WHERE sectorid = {?}", $sect);
$page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN);
$page->assign('id', $id);
$page->assign('ssecteurs', $res);
$page->assign('sel', $ssect);
+ if ($id != -1) {
+ $page->assign('change', 1);
+ $page->assign('jobid', $jobid);
+ $page->assign('jobpref', $jobpref);
+ }
+ }
+
+ function handler_ajax_ssecteur(&$page, $id, $ssect, $sssect = -1)
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $res = XDB::iterator("SELECT id, name AS label
+ FROM profile_job_subsubsector_enum
+ WHERE subsectorid = {?}", $ssect);
+ $page->changeTpl('profile/jobs.soussecteur.tpl', NO_SKIN);
+ $page->assign('id', $id);
+ $page->assign('sssecteurs', $res);
+ $page->assign('sel', $sssect);
}
function handler_ajax_skill(&$page, $cat, $id)
require_once 'validations.inc.php';
- $res = XDB::query(
- "SELECT u.promo, u.promo_sortie
- FROM auth_user_md5 AS u
- WHERE user_id={?}", S::v('uid'));
+ $res = XDB::query("SELECT e.entry_year, e.grad_year, d.promo, FIND_IN_SET('femme', u.flags) AS sexe
+ FROM auth_user_md5 AS u
+ INNER JOIN profile_display AS d ON (d.pid = u.user_id)
+ INNER JOIN profile_education AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags))
+ WHERE u.user_id = {?}", S::v('uid'));
- list($promo, $promo_sortie_old) = $res->fetchOneRow();
+ list($promo, $promo_sortie_old, $promo_display, $sexe) = $res->fetchOneRow();
$page->assign('promo_sortie_old', $promo_sortie_old);
- $page->assign('promo', $promo);
+ $page->assign('promo', $promo);
+ $page->assign('promo_display', $promo_display);
+ $page->assign('sexe', $sexe);
if (!Env::has('promo_sortie')) {
return;
$promo_sortie = Env::i('promo_sortie');
if ($promo_sortie < 1000 || $promo_sortie > 9999) {
- $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
+ $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres.');
}
elseif ($promo_sortie < $promo + 3) {
- $page->trigError('Trop tôt');
+ $page->trigError('Trop tôt !');
}
elseif ($promo_sortie == $promo_sortie_old) {
$page->trigWarning('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'));
+ XDB::execute("UPDATE profile_education
+ SET grad_year = {?}
+ WHERE uid = {?} AND FIND_IN_SET('primary', flags)", $promo_sortie, S::v('uid'));
$page->trigSuccess('Ton statut "orange" a été supprimé.');
$page->assign('promo_sortie_old', $promo_sortie);
}
///// recuperations infos referent
//expertise
- $res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", $user->id());
+ $res = XDB::query("SELECT expertise FROM profile_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)
+ "SELECT s.name AS label, ss.name AS label
+ FROM profile_mentor_sector AS m
+ LEFT JOIN profile_job_sector_enum AS s ON(m.sectorid = s.id)
+ LEFT JOIN profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id)
WHERE uid = {?}", $user->id());
while (list($sec, $ssec) = $res->next()) {
$secteurs[] = $sec;
//pays
$res = XDB::query(
"SELECT gp.pays
- FROM mentor_pays AS m
- LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
+ FROM profile_mentor_country AS m
+ LEFT JOIN geoloc_pays AS gp ON (m.country = gp.a2)
WHERE uid = {?}", $user->id());
$page->assign('pays', $res->fetchColumn());
$page->setTitle('Conseil Pro');
//recuperation des noms de secteurs
- $res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
+ $res = XDB::iterRow("SELECT id, name AS label FROM profile_job_sector_enum");
$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");
+ $res = XDB::query("SELECT count(*) FROM profile_mentor");
$page->assign('mentors_number', $res->fetchOneCell());
// On vient d'un formulaire
$expertise_champ = XDB::escape(Env::v('expertise'));
if ($pays_sel != "''") {
- $where[] = "mp.pid = $pays_sel";
+ $where[] = "mp.country = $pays_sel";
}
if ($secteur_sel != "''") {
- $where[] = "ms.secteur = $secteur_sel";
+ $where[] = "ms.sectorid = $secteur_sel";
if ($ss_secteur_sel != "''") {
- $where[] = "ms.ss_secteur = $ss_secteur_sel";
+ $where[] = "ms.subsectorid = $ss_secteur_sel";
}
}
if ($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)",
+ $set = new UserSet("INNER JOIN profile_mentor AS m ON (m.uid = u.user_id)
+ LEFT JOIN profile_mentor_country AS mp ON (mp.uid = m.uid)
+ LEFT JOIN profile_mentor_sector AS ms ON (ms.uid = m.uid)",
$where);
$set->addMod('mentor', 'Référents');
$set->apply('referent/search', $page, $action, $subaction);
$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);
+ $it = XDB::iterator("SELECT id, name AS field
+ FROM profile_job_subsector_enum
+ WHERE sectorid = {?}", $sect);
$page->assign('list', $it);
}
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 = {?}' : '');
+ $where = ($ssect ? ' AND ms.subsectorid = {?}' : '');
$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);
+ FROM geoloc_pays AS g
+ INNER JOIN profile_mentor_country AS mp ON (mp.country = g.a2)
+ INNER JOIN profile_mentor_sector AS ms ON (ms.uid = mp.uid)
+ WHERE ms.sectorid = {?} $where
+ GROUP BY a2
+ ORDER BY pays", $sect, $ssect);
$page->assign('list', $it);
}