2 /***************************************************************************
3 * Copyright (C) 2003-2008 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class ProfileModule
extends PLModule
27 'photo' => $this->make_hook('photo', AUTH_PUBLIC
),
28 'photo/change' => $this->make_hook('photo_change', AUTH_MDP
),
30 'fiche.php' => $this->make_hook('fiche', AUTH_PUBLIC
),
31 'profile' => $this->make_hook('profile', AUTH_PUBLIC
),
32 'profile/private' => $this->make_hook('profile', AUTH_COOKIE
),
33 'profile/ax' => $this->make_hook('ax', AUTH_COOKIE
, 'admin'),
34 'profile/edit' => $this->make_hook('p_edit', AUTH_MDP
),
35 'profile/ajax/address' => $this->make_hook('ajax_address', AUTH_COOKIE
, 'user', NO_AUTH
),
36 'profile/ajax/tel' => $this->make_hook('ajax_tel', AUTH_COOKIE
, 'user', NO_AUTH
),
37 'profile/ajax/edu' => $this->make_hook('ajax_edu', AUTH_COOKIE
, 'user', NO_AUTH
),
38 'profile/ajax/medal' => $this->make_hook('ajax_medal', AUTH_COOKIE
, 'user', NO_AUTH
),
39 'profile/networking' => $this->make_hook('networking', AUTH_PUBLIC
),
40 'profile/ajax/job' => $this->make_hook('ajax_job', AUTH_COOKIE
, 'user', NO_AUTH
),
41 'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE
, 'user', NO_AUTH
),
42 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE
, 'user', NO_AUTH
),
43 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE
, 'user', NO_AUTH
),
44 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE
),
45 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE
),
46 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC
),
47 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP
),
48 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP
),
50 'referent' => $this->make_hook('referent', AUTH_COOKIE
),
51 'emploi' => $this->make_hook('ref_search', AUTH_COOKIE
),
52 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE
),
53 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE
, 'user', NO_AUTH
),
54 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE
, 'user', NO_AUTH
),
56 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE
),
58 'vcard' => $this->make_hook('vcard', AUTH_COOKIE
, 'user', NO_HTTPS
),
59 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP
, 'admin'),
60 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP
, 'admin'),
61 'admin/education' => $this->make_hook('admin_education', AUTH_MDP
, 'admin'),
62 'admin/education_field' => $this->make_hook('admin_education_field', AUTH_MDP
, 'admin'),
63 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_MDP
, 'admin'),
64 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP
, 'admin'),
65 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP
, 'admin'),
66 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP
, 'admin'),
67 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP
, 'admin'),
68 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP
, 'admin'),
69 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP
, 'admin'),
70 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP
, 'admin'),
76 function handler_fiche(&$page)
78 return $this->handler_profile($page, Env
::v('user'));
81 function handler_photo(&$page, $x = null
, $req = null
)
87 $res = XDB
::query("SELECT id, pub FROM aliases
88 LEFT JOIN photo ON(id = uid)
89 WHERE alias = {?}", $x);
90 list($uid, $photo_pub) = $res->fetchOneRow();
92 if ($req && S
::logged()) {
93 include 'validations.inc.php';
94 $myphoto = PhotoReq
::get_request($uid);
95 Header('Content-type: image/'.$myphoto->mimetype
);
99 "SELECT attachmime, attach
101 WHERE uid={?}", $uid);
103 if ((list($type, $data) = $res->fetchOneRow())
104 && ($photo_pub == 'public' || S
::logged())) {
105 Header("Content-type: image/$type");
108 Header('Content-type: image/png');
109 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
115 function handler_medal(&$page, $mid)
117 $thumb = ($mid == 'thumb');
118 $mid = $thumb ? @func_get_arg
(2) : $mid;
120 $res = XDB
::query("SELECT img
125 dirname(__FILE__
).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() :
126 dirname(__FILE__
).'/../htdocs/images/medals/' . $res->fetchOneCell();
127 $type = mime_content_type($img);
128 header("Content-Type: $type");
129 echo file_get_contents($img);
133 function handler_networking(&$page, $mid)
135 $res = XDB
::query("SELECT icon
136 FROM profile_networking_enum
137 WHERE network_type = {?}",
139 $img = dirname(__FILE__
) . '/../htdocs/images/networking/' . $res->fetchOneCell();
140 $type = mime_content_type($img);
141 header("Content-Type: $type");
142 echo file_get_contents($img);
146 function handler_photo_change(&$page)
149 $page->changeTpl('profile/trombino.tpl');
151 require_once('validations.inc.php');
153 $trombi_x = '/home/web/trombino/photos'.S
::v('promo')
154 .'/'.S
::v('forlife').'.jpg';
156 if (Env
::has('upload')) {
157 S
::assert_xsrf_token();
159 $upload = new PlUpload(S
::v('forlife'), 'photo');
160 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
161 $page->trigError('Une erreur est survenue lors du téléchargement du fichier');
163 $myphoto = new PhotoReq(S
::v('uid'), $upload);
164 if ($myphoto->isValid()) {
168 } elseif (Env
::has('trombi')) {
169 S
::assert_xsrf_token();
171 $upload = new PlUpload(S
::v('forlife'), 'photo');
172 if ($upload->copyFrom($trombi_x)) {
173 $myphoto = new PhotoReq(S
::v('uid'), $upload);
174 if ($myphoto->isValid()) {
179 } elseif (Env
::v('suppr')) {
180 S
::assert_xsrf_token();
182 XDB
::execute('DELETE FROM photo
185 XDB
::execute('DELETE FROM requests
186 WHERE user_id = {?} AND type="photo"',
188 $globals->updateNbValid();
189 } elseif (Env
::v('cancel')) {
190 S
::assert_xsrf_token();
192 $sql = XDB
::query('DELETE FROM requests
193 WHERE user_id={?} AND type="photo"',
195 $globals->updateNbValid();
198 $sql = XDB
::query('SELECT COUNT(*)
200 WHERE user_id={?} AND type="photo"',
202 $page->assign('submited', $sql->fetchOneCell());
203 $page->assign('has_trombi_x', file_exists($trombi_x));
206 function handler_profile(&$page, $x = null
)
213 require_once 'user.func.inc.php';
215 $page->changeTpl('profile/profile.tpl', SIMPLE
);
218 if (!S
::logged() || Env
::v('view') == 'public') $view = 'public';
219 if (S
::logged() && Env
::v('view') == 'ax') $view = 'ax';
221 if (is_numeric($x)) {
225 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
226 WHERE matricule={?}", $x);
227 $login = $res->fetchOneCell();
229 $login = get_user_forlife($x, S
::logged() ?
'_default_user_callback'
230 : '_silent_user_callback');
234 $user = get_not_registered_user($x, true
);
235 if ($user->total() != 1) {
238 $user = $user->next();
240 pl_redirect('marketing/public/' . $user['user_id']);
242 $user['forlife'] = $x;
244 $new = Env
::v('modif') == 'new';
245 $user = get_user_details($login, S
::v('uid'), $view);
249 S
::logger()->log('view_profile', $login);
252 $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ?
$user['nom'] : $user['nom_usage'] );
253 $page->setTitle($title);
257 $photo = 'photo/'.$user['forlife'].($new ?
'/req' : '');
259 if (!isset($user['y']) and !isset($user['x'])) {
260 list($user['x'], $user['y']) = getimagesize("images/none.png");
262 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
263 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
264 if ($user['x'] > 240) {
265 $user['y'] = (integer)($user['y']*240/$user['x']);
268 if ($user['y'] > 300) {
269 $user['x'] = (integer)($user['x']*300/$user['y']);
272 if ($user['x'] < 160) {
273 $user['y'] = (integer)($user['y']*160/$user['x']);
277 $page->assign('logged', has_user_right('private', $view));
278 if (!has_user_right($user['photo_pub'], $view)) {
282 $page->assign_by_ref('x', $user);
283 $page->assign('photo_url', $photo);
288 INNER JOIN virtual_redirect USING(vid)
289 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
290 WHERE ( redirect={?} OR redirect={?} )
291 AND alias LIKE '%@{$globals->mail->alias_dom}'",
293 $user['forlife'].'@'.$globals->mail
->domain
,
294 $user['forlife'].'@'.$globals->mail
->domain2
);
295 $page->assign('virtualalias', $res->fetchOneCell());
296 $page->assign('view', $view);
298 $page->addJsLink('close_on_esc.js');
299 header('Last-Modified: ' . date('r', strtotime($user['date'])));
302 function handler_ax(&$page, $user = null
)
304 require_once 'user.func.inc.php';
305 $user = get_user_forlife($user);
309 $res = XDB
::query('SELECT matricule_ax
310 FROM auth_user_md5 AS u
311 INNER JOIN aliases AS a ON (a.type = "a_vie" AND a.id = u.user_id)
312 WHERE a.alias = {?}', $user);
313 $mat = $res->fetchOneCell();
315 $page->kill("Le matricule AX de $user est inconnu");
317 http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
320 function handler_p_edit(&$page, $opened_tab = null
, $mode = null
)
324 // AX Synchronization
325 require_once 'synchro_ax.inc.php';
326 if (is_ax_key_missing()) {
327 $page->assign('no_private_key', true
);
329 if (Env
::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
330 ax_synchronize(S
::v('bestalias'), S
::v('uid'));
331 $page->trigSuccess('Ton profil a été synchronisé avec celui du site polytechniciens.com');
335 $page->addJsLink('ajax.js');
336 $page->addJsLink('education.js');
337 $page->addJsLink('grades.js');
338 $page->addJsLink('profile.js');
339 $page->addJsLink('jquery.autocomplete.js');
340 $wiz = new PlWizard('Profil', PlPage
::getCoreTpl('plwizard.tpl'), true
, true
);
341 $this->load('page.inc.php');
342 $wiz->addPage('ProfileGeneral', 'Général', 'general');
343 $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
344 $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
345 $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco');
346 $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
347 $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
348 $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
349 $wiz->apply($page, 'profile/edit', $opened_tab, $mode);
352 $res = XDB
::query("SELECT user_id
354 WHERE user_id = {?} AND naissance = '0000-00-00'", S
::i('uid'));
355 if ($res->numRows()) {
356 $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
357 . " la procédure de récupération de mot de passe si un jour tu le perdais");
360 $page->setTitle('Mon Profil');
363 function handler_education_js(&$page)
365 header('Content-Type: text/javascript; charset=utf-8');
366 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
367 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
368 header('Cache-Control: no-cache, must-revalidate');
369 header('Pragma: no-cache');
370 $page->changeTpl('profile/education.js.tpl', NO_SKIN
);
371 require_once "education.func.inc.php";
374 function handler_grades_js(&$page)
376 header('Content-Type: text/javascript; charset=utf-8');
377 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
378 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
379 header('Cache-Control: no-cache, must-revalidate');
380 header('Pragma: no-cache');
381 $page->changeTpl('profile/grades.js.tpl', NO_SKIN
);
382 $res = XDB
::iterator("SELECT *
383 FROM profile_medals_grades
386 while ($tmp = $res->next()) {
387 $grades[$tmp['mid']][] = $tmp;
389 $page->assign('grades', $grades);
391 $res = XDB
::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
393 ORDER BY type, text");
395 while ($tmp = $res->next()) {
396 $mlist[$tmp['type']][] = $tmp;
398 $page->assign('medal_list', $mlist);
401 function handler_ajax_address(&$page, $adid)
403 header('Content-Type: text/html; charset=utf-8');
404 $page->changeTpl('profile/adresses.address.tpl', NO_SKIN
);
405 $page->assign('i', $adid);
406 $page->assign('adr', array());
409 function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
411 header('Content-Type: text/html; charset=utf-8');
412 $page->changeTpl('profile/phone.tpl', NO_SKIN
);
413 $page->assign('prefid', $prefid);
414 $page->assign('prefname', $prefname);
415 $page->assign('telid', $telid);
416 $page->assign('tel', array());
419 function handler_ajax_edu(&$page, $eduid, $class)
421 header('Content-Type: text/html; charset=utf-8');
422 $page->changeTpl('profile/edu.tpl', NO_SKIN
);
423 $res = XDB
::iterator("SELECT id, field
424 FROM profile_education_field_enum
426 $page->assign('edu_fields', $res->fetchAllAssoc());
427 $page->assign('eduid', $eduid);
428 $page->assign('class', $class);
429 require_once "education.func.inc.php";
432 function handler_ajax_medal(&$page, $id)
434 header('Content-Type: text/html; charset=utf-8');
435 $page->changeTpl('profile/deco.medal.tpl', NO_SKIN
);
436 $page->assign('id', $id);
437 $page->assign('medal', array('valid' => 0, 'grade' => 0));
440 function handler_ajax_job(&$page, $id)
442 header('Content-Type: text/html; charset=utf-8');
443 $page->changeTpl('profile/jobs.job.tpl', NO_SKIN
);
444 $page->assign('i', $id);
445 $page->assign('job', array());
446 $page->assign('new', true
);
447 $page->assign('secteurs', XDB
::iterator("SELECT id, label
448 FROM emploi_secteur"));
449 $page->assign('fonctions', XDB
::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
454 function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
456 header('Content-Type: text/html; charset=utf-8');
457 $res = XDB
::iterator("SELECT id, label
458 FROM emploi_ss_secteur
459 WHERE secteur = {?}", $sect);
460 $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN
);
461 $page->assign('id', $id);
462 $page->assign('ssecteurs', $res);
463 $page->assign('sel', $ssect);
466 function handler_ajax_skill(&$page, $cat, $id)
468 header('Content-Type: text/html; charset=utf-8');
469 $page->changeTpl('profile/skill.skill.tpl', NO_SKIN
);
470 $page->assign('cat', $cat);
471 $page->assign('id', $id);
472 if ($cat == 'competences') {
473 $page->assign('levels', array('initié' => 'initié',
474 'bonne connaissance' => 'bonne connaissance',
475 'expert' => 'expert'));
477 $page->assign('levels', array(1 => 'connaissance basique',
478 2 => 'maîtrise des bases',
479 3 => 'maîtrise limitée',
480 4 => 'maîtrise générale',
481 5 => 'bonne maîtrise',
482 6 => 'maîtrise complète'));
486 function handler_ajax_searchname(&$page, $snid)
488 header('Content-Type: text/html; charset=utf-8');
489 $page->changeTpl('profile/general.searchname.tpl', NO_SKIN
);
490 $page->assign('i', $snid);
491 $page->assign('sn', array());
492 $page->assign('newsn', true
);
495 function handler_p_orange(&$page)
497 $page->changeTpl('profile/orange.tpl');
499 require_once 'validations.inc.php';
502 "SELECT u.promo, u.promo_sortie
503 FROM auth_user_md5 AS u
504 WHERE user_id={?}", S
::v('uid'));
506 list($promo, $promo_sortie_old) = $res->fetchOneRow();
507 $page->assign('promo_sortie_old', $promo_sortie_old);
508 $page->assign('promo', $promo);
510 if (!Env
::has('promo_sortie')) {
513 S
::assert_xsrf_token();
516 $promo_sortie = Env
::i('promo_sortie');
518 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
519 $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
521 elseif ($promo_sortie < $promo +
3) {
522 $page->trigError('Trop tôt');
524 elseif ($promo_sortie == $promo_sortie_old) {
525 $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
527 elseif ($promo_sortie == $promo +
3) {
529 "UPDATE auth_user_md5 set promo_sortie={?}
530 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
531 $page->trigSuccess('Ton statut "orange" a été supprimé.');
532 $page->assign('promo_sortie_old', $promo_sortie);
535 $page->assign('promo_sortie', $promo_sortie);
537 if (Env
::has('submit')) {
538 $myorange = new OrangeReq(S
::v('uid'),
541 $page->assign('myorange', $myorange);
546 function handler_referent(&$page, $x = null
)
548 require_once 'user.func.inc.php';
554 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
557 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
558 FROM auth_user_md5 AS u
559 INNER JOIN aliases AS a ON (u.user_id=a.id
560 AND FIND_IN_SET('bestalias', a.flags))
561 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
563 AND a1.type!='homonyme')", $x);
565 if ($res->numRows() != 1) {
569 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
571 $page->assign('prenom', $prenom);
572 $page->assign('nom', $nom);
573 $page->assign('promo', $promo);
574 $page->assign('cv', MiniWiki
::WikiToHTML($cv, true
));
575 $page->assign('bestalias', $bestalias);
576 $page->assign('adr_pro', get_user_details_pro($user_id));
578 ///// recuperations infos referent
581 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
582 $page->assign('expertise', $res->fetchOneCell());
585 $secteurs = $ss_secteurs = Array();
587 "SELECT s.label, ss.label
588 FROM mentor_secteurs AS m
589 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
590 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
591 WHERE uid = {?}", $user_id);
592 while (list($sec, $ssec) = $res->next()) {
594 $ss_secteurs[] = $ssec;
596 $page->assign_by_ref('secteurs', $secteurs);
597 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
602 FROM mentor_pays AS m
603 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
604 WHERE uid = {?}", $user_id);
605 $page->assign('pays', $res->fetchColumn());
607 $page->addJsLink('close_on_esc.js');
610 function handler_ref_search(&$page, $action = null
, $subaction = null
)
612 $wp = new PlWikiPage('Docs.Emploi');
615 $page->setTitle('Conseil Pro');
617 //recuperation des noms de secteurs
618 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
620 while (list($tmp_id, $tmp_label) = $res->next()) {
621 $secteurs[$tmp_id] = $tmp_label;
623 $page->assign_by_ref('secteurs', $secteurs);
626 $res = XDB
::query("SELECT count(*) FROM mentor");
627 $page->assign('mentors_number', $res->fetchOneCell());
629 // On vient d'un formulaire
631 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
632 $secteur_sel = XDB
::escape(Env
::v('secteur'));
633 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
634 $expertise_champ = XDB
::escape(Env
::v('expertise'));
636 if ($pays_sel != "''") {
637 $where[] = "mp.pid = $pays_sel";
639 if ($secteur_sel != "''") {
640 $where[] = "ms.secteur = $secteur_sel";
641 if ($ss_secteur_sel != "''") {
642 $where[] = "ms.ss_secteur = $ss_secteur_sel";
645 if ($expertise_champ != "''") {
646 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
650 $where = join(' AND ', $where);
652 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
653 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
654 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
656 $set->addMod('mentor', 'Référents');
657 $set->apply('referent/search', $page, $action, $subaction);
658 if ($set->count() > 100) {
659 $page->assign('recherche_trop_large', true
);
662 $page->changeTpl('profile/referent.tpl');
665 function handler_ref_sect(&$page, $sect)
667 header('Content-Type: text/html; charset=utf-8');
668 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
669 $page->assign('onchange', 'setSSecteurs()');
670 $page->assign('id', 'ssect_field');
671 $page->assign('name', 'ss_secteur');
672 $it = XDB
::iterator("SELECT id,label AS field
673 FROM emploi_ss_secteur
674 WHERE secteur = {?}", $sect);
675 $page->assign('list', $it);
678 function handler_ref_country(&$page, $sect, $ssect = '')
680 header('Content-Type: text/html; charset=utf-8');
681 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
682 $page->assign('name', 'pays_sel');
683 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
684 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
685 FROM geoloc_pays AS g
686 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
687 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
688 WHERE ms.secteur = {?} $where
690 ORDER BY pays", $sect, $ssect);
691 $page->assign('list', $it);
694 function handler_p_usage(&$page)
696 $page->changeTpl('profile/nomusage.tpl');
698 require_once 'validations.inc.php';
701 "SELECT u.nom, u.nom_usage, u.flags, e.alias
702 FROM auth_user_md5 AS u
703 LEFT JOIN aliases AS e ON(u.user_id = e.id
704 AND FIND_IN_SET('usage', e.flags))
705 WHERE user_id={?}", S
::v('uid'));
707 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
708 $flags = new PlFlagSet($flags);
709 $page->assign('usage_old', $usage_old);
710 $page->assign('alias_old', $alias_old);
712 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
713 $nom_usage = strtoupper($nom_usage);
714 $page->assign('usage_req', $nom_usage);
716 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
717 S
::assert_xsrf_token();
719 // on vient de recevoir une requete, differente de l'ancien nom d'usage
720 if ($nom_usage == $nom) {
721 $page->assign('same', true
);
722 } else { // le nom de mariage est distinct du nom à l'X
723 // on calcule l'alias pour l'afficher
724 $reason = Env
::v('reason');
725 if ($reason == 'other') {
726 $reason = Env
::v('other_reason');
728 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
730 $page->assign('myusage', $myusage);
735 function handler_xnet(&$page)
737 $page->changeTpl('profile/groupesx.tpl');
738 $page->setTitle('Promo, Groupes X, Binets');
741 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
742 COUNT(e.eid) AS events, mail_domain AS lists
743 FROM groupex.membres AS m
744 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
745 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
746 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
747 $page->assign('assos', $req->fetchAllAssoc());
750 function handler_vcard(&$page, $x = null
)
758 if (substr($x, -4) == '.vcf') {
759 $x = substr($x, 0, strlen($x) - 4);
762 $vcard = new VCard();
767 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
768 $page->changeTpl('profile/admin_trombino.tpl');
769 $page->setTitle('Administration - Trombino');
770 $page->assign('uid', $uid);
773 "SELECT a.alias,promo
774 FROM auth_user_md5 AS u
775 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
776 WHERE user_id = {?}", $uid);
777 list($forlife, $promo) = $q->fetchOneRow();
781 header("Content-type: image/jpeg");
782 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
787 S
::assert_xsrf_token();
789 $data = file_get_contents($_FILES['userfile']['tmp_name']);
790 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
791 $mimetype = substr($_FILES['userfile']['type'], 6);
792 unlink($_FILES['userfile']['tmp_name']);
794 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
795 $uid, $mimetype, $data, $x, $y);
799 S
::assert_xsrf_token();
801 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
805 $page->assign('forlife', $forlife);
807 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
808 $page->setTitle('Administration - Binets');
809 $page->assign('title', 'Gestion des binets');
810 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
811 $table_editor->add_join_table('binets_ins','binet_id',true
);
812 $table_editor->describe('text','intitulé',true
);
813 $table_editor->apply($page, $action, $id);
815 function handler_admin_education(&$page, $action = 'list', $id = null
) {
816 $page->setTitle('Administration - Formations');
817 $page->assign('title', 'Gestion des formations');
818 $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id');
819 $table_editor->add_join_table('profile_education', 'eduid', true
);
820 $table_editor->add_join_table('profile_education_degree', 'eduid', true
);
821 $table_editor->describe('name', 'intitulé', true
);
822 $table_editor->describe('url', 'site web', false
);
823 $table_editor->apply($page, $action, $id);
825 function handler_admin_education_field(&$page, $action = 'list', $id = null
) {
826 $page->setTitle('Administration - Domaines de formation');
827 $page->assign('title', 'Gestion des domaines de formation');
828 $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true
);
829 $table_editor->add_join_table('profile_education', 'fieldid', true
);
830 $table_editor->describe('field', 'domaine', true
);
831 $table_editor->apply($page, $action, $id);
833 function handler_admin_education_degree(&$page, $action = 'list', $id = null
) {
834 $page->setTitle('Administration - Niveau de formation');
835 $page->assign('title', 'Gestion des niveau de formation');
836 $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id', true
);
837 $table_editor->add_join_table('profile_education_degree', 'degreeid', true
);
838 $table_editor->add_join_table('profile_education', 'degreeid', true
);
839 $table_editor->describe('degree', 'niveau', true
);
840 $table_editor->apply($page, $action, $id);
842 function handler_admin_education_degree_set(&$page, $action = 'list', $id = null
) {
843 $page->setTitle('Administration - Correspondances formations - niveau de formation');
844 $page->assign('title', 'Gestion des correspondances formations - niveau de formation');
845 $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true
);
846 $table_editor->describe('eduid', 'formation', true
);
847 $table_editor->describe('degreeid', 'niveau', true
);
848 $table_editor->apply($page, $action, $id);
850 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
851 $page->setTitle('Administration - Sections');
852 $page->assign('title', 'Gestion des sections');
853 $table_editor = new PLTableEditor('admin/sections','sections','id');
854 $table_editor->describe('text','intitulé',true
);
855 $table_editor->apply($page, $action, $id);
857 function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null
) {
858 $page->setTitle('Administration - Sous-secteurs');
859 $page->assign('title', 'Gestion des sous-secteurs');
860 $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true
);
861 $table_editor->describe('label', 'intitulé', true
);
862 $table_editor->apply($page, $action, $id);
864 function handler_admin_fonctions(&$page, $action = 'list', $id = null
) {
865 $page->setTitle('Administration - Fonctions');
866 $page->assign('title', 'Gestion des fonctions');
867 $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true
);
868 $table_editor->describe('fonction_fr', 'intitulé', true
);
869 $table_editor->describe('fonction_en', 'intitulé (ang)', true
);
870 $table_editor->describe('flags', 'titre', true
);
871 $table_editor->apply($page, $action, $id);
873 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
874 $page->setTitle('Administration - Secteurs');
875 $page->assign('title', 'Gestion des secteurs');
876 $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true
);
877 $table_editor->describe('label', 'intitulé', true
);
878 $table_editor->apply($page, $action, $id);
880 function handler_admin_networking(&$page, $action = 'list', $id = null
) {
881 $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
882 $page->assign('title', 'Gestion des types de networking');
883 $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
884 $table_editor->describe('name', 'intitulé', true
);
885 $table_editor->describe('icon', 'nom de l\'icône', false
);
886 $table_editor->describe('filter', 'filtre', true
);
887 $table_editor->describe('link', 'lien web', true
);
888 $table_editor->apply($page, $action, $id);
890 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
891 $page->setTitle('Administration - Distinctions');
892 $page->assign('title', 'Gestion des Distinctions');
893 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
894 $table_editor->describe('text', 'intitulé', true
);
895 $table_editor->describe('img', 'nom de l\'image', false
);
896 $table_editor->describe('flags', 'valider', true
);
897 $table_editor->apply($page, $action, $id);
898 if ($id && $action == 'edit') {
899 $page->changeTpl('profile/admin_decos.tpl');
903 if (Post
::v('act') == 'del') {
904 XDB
::execute('DELETE FROM profile_medals_grades
905 WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
907 foreach (Post
::v('grades', array()) as $gid=>$text) {
910 $res = XDB
::query('SELECT MAX(gid)
911 FROM profile_medals_grades
912 WHERE mid = {?}', $mid);
913 $gid = $res->fetchOneCell() +
1;
915 XDB
::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos)
916 VALUES ({?}, {?}, {?}, {?})',
917 $mid, $gid, $text, $_POST['pos']['0']);
920 XDB
::execute('UPDATE profile_medals_grades
921 SET pos={?}, text={?}
922 WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
926 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
927 $page->assign('grades', $res);
932 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: