419b3bff0c96097fc9695cecc5f7e1b87814ba45
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/applis.js' => $this->make_hook('applis_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('applis.js');
337 $page->addJsLink('grades.js');
338 $page->addJsLink('profile.js');
339 $page->addJsLink('jquery.autocomplete.js');
340 $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true
, true
);
341 require_once dirname(__FILE__
) . '/profile/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_applis_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/applis.js.tpl', NO_SKIN
);
371 require_once "applis.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)
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 require_once "applis.func.inc.php";
431 function handler_ajax_medal(&$page, $id)
433 header('Content-Type: text/html; charset=utf-8');
434 $page->changeTpl('profile/deco.medal.tpl', NO_SKIN
);
435 $page->assign('id', $id);
436 $page->assign('medal', array('valid' => 0, 'grade' => 0));
439 function handler_ajax_job(&$page, $id)
441 header('Content-Type: text/html; charset=utf-8');
442 $page->changeTpl('profile/jobs.job.tpl', NO_SKIN
);
443 $page->assign('i', $id);
444 $page->assign('job', array());
445 $page->assign('new', true
);
446 $page->assign('secteurs', XDB
::iterator("SELECT id, label
447 FROM emploi_secteur"));
448 $page->assign('fonctions', XDB
::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
453 function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
455 header('Content-Type: text/html; charset=utf-8');
456 $res = XDB
::iterator("SELECT id, label
457 FROM emploi_ss_secteur
458 WHERE secteur = {?}", $sect);
459 $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN
);
460 $page->assign('id', $id);
461 $page->assign('ssecteurs', $res);
462 $page->assign('sel', $ssect);
465 function handler_ajax_skill(&$page, $cat, $id)
467 header('Content-Type: text/html; charset=utf-8');
468 $page->changeTpl('profile/skill.skill.tpl', NO_SKIN
);
469 $page->assign('cat', $cat);
470 $page->assign('id', $id);
471 if ($cat == 'competences') {
472 $page->assign('levels', array('initié' => 'initié',
473 'bonne connaissance' => 'bonne connaissance',
474 'expert' => 'expert'));
476 $page->assign('levels', array(1 => 'connaissance basique',
477 2 => 'maîtrise des bases',
478 3 => 'maîtrise limitée',
479 4 => 'maîtrise générale',
480 5 => 'bonne maîtrise',
481 6 => 'maîtrise complète'));
485 function handler_ajax_searchname(&$page, $snid)
487 header('Content-Type: text/html; charset=utf-8');
488 $page->changeTpl('profile/general.searchname.tpl', NO_SKIN
);
489 $page->assign('i', $snid);
490 $page->assign('sn', array());
491 $page->assign('newsn', true
);
494 function handler_p_orange(&$page)
496 $page->changeTpl('profile/orange.tpl');
498 require_once 'validations.inc.php';
501 "SELECT u.promo, u.promo_sortie
502 FROM auth_user_md5 AS u
503 WHERE user_id={?}", S
::v('uid'));
505 list($promo, $promo_sortie_old) = $res->fetchOneRow();
506 $page->assign('promo_sortie_old', $promo_sortie_old);
507 $page->assign('promo', $promo);
509 if (!Env
::has('promo_sortie')) {
512 S
::assert_xsrf_token();
515 $promo_sortie = Env
::i('promo_sortie');
517 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
518 $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
520 elseif ($promo_sortie < $promo +
3) {
521 $page->trigError('Trop tôt');
523 elseif ($promo_sortie == $promo_sortie_old) {
524 $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
526 elseif ($promo_sortie == $promo +
3) {
528 "UPDATE auth_user_md5 set promo_sortie={?}
529 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
530 $page->trigSuccess('Ton statut "orange" a été supprimé.');
531 $page->assign('promo_sortie_old', $promo_sortie);
534 $page->assign('promo_sortie', $promo_sortie);
536 if (Env
::has('submit')) {
537 $myorange = new OrangeReq(S
::v('uid'),
540 $page->assign('myorange', $myorange);
545 function handler_referent(&$page, $x = null
)
547 require_once 'user.func.inc.php';
553 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
556 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
557 FROM auth_user_md5 AS u
558 INNER JOIN aliases AS a ON (u.user_id=a.id
559 AND FIND_IN_SET('bestalias', a.flags))
560 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
562 AND a1.type!='homonyme')", $x);
564 if ($res->numRows() != 1) {
568 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
570 $page->assign('prenom', $prenom);
571 $page->assign('nom', $nom);
572 $page->assign('promo', $promo);
573 $page->assign('cv', MiniWiki
::WikiToHTML($cv, true
));
574 $page->assign('bestalias', $bestalias);
575 $page->assign('adr_pro', get_user_details_pro($user_id));
577 ///// recuperations infos referent
580 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
581 $page->assign('expertise', $res->fetchOneCell());
584 $secteurs = $ss_secteurs = Array();
586 "SELECT s.label, ss.label
587 FROM mentor_secteurs AS m
588 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
589 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
590 WHERE uid = {?}", $user_id);
591 while (list($sec, $ssec) = $res->next()) {
593 $ss_secteurs[] = $ssec;
595 $page->assign_by_ref('secteurs', $secteurs);
596 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
601 FROM mentor_pays AS m
602 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
603 WHERE uid = {?}", $user_id);
604 $page->assign('pays', $res->fetchColumn());
606 $page->addJsLink('close_on_esc.js');
609 function handler_ref_search(&$page, $action = null
, $subaction = null
)
611 $wp = new PlWikiPage('Docs.Emploi');
614 $page->setTitle('Conseil Pro');
616 //recuperation des noms de secteurs
617 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
619 while (list($tmp_id, $tmp_label) = $res->next()) {
620 $secteurs[$tmp_id] = $tmp_label;
622 $page->assign_by_ref('secteurs', $secteurs);
625 $res = XDB
::query("SELECT count(*) FROM mentor");
626 $page->assign('mentors_number', $res->fetchOneCell());
628 // On vient d'un formulaire
630 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
631 $secteur_sel = XDB
::escape(Env
::v('secteur'));
632 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
633 $expertise_champ = XDB
::escape(Env
::v('expertise'));
635 if ($pays_sel != "''") {
636 $where[] = "mp.pid = $pays_sel";
638 if ($secteur_sel != "''") {
639 $where[] = "ms.secteur = $secteur_sel";
640 if ($ss_secteur_sel != "''") {
641 $where[] = "ms.ss_secteur = $ss_secteur_sel";
644 if ($expertise_champ != "''") {
645 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
649 $where = join(' AND ', $where);
651 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
652 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
653 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
655 $set->addMod('mentor', 'Référents');
656 $set->apply('referent/search', $page, $action, $subaction);
657 if ($set->count() > 100) {
658 $page->assign('recherche_trop_large', true
);
661 $page->changeTpl('profile/referent.tpl');
664 function handler_ref_sect(&$page, $sect)
666 header('Content-Type: text/html; charset=utf-8');
667 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
668 $page->assign('onchange', 'setSSecteurs()');
669 $page->assign('id', 'ssect_field');
670 $page->assign('name', 'ss_secteur');
671 $it = XDB
::iterator("SELECT id,label AS field
672 FROM emploi_ss_secteur
673 WHERE secteur = {?}", $sect);
674 $page->assign('list', $it);
677 function handler_ref_country(&$page, $sect, $ssect = '')
679 header('Content-Type: text/html; charset=utf-8');
680 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
681 $page->assign('name', 'pays_sel');
682 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
683 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
684 FROM geoloc_pays AS g
685 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
686 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
687 WHERE ms.secteur = {?} $where
689 ORDER BY pays", $sect, $ssect);
690 $page->assign('list', $it);
693 function handler_p_usage(&$page)
695 $page->changeTpl('profile/nomusage.tpl');
697 require_once 'validations.inc.php';
700 "SELECT u.nom, u.nom_usage, u.flags, e.alias
701 FROM auth_user_md5 AS u
702 LEFT JOIN aliases AS e ON(u.user_id = e.id
703 AND FIND_IN_SET('usage', e.flags))
704 WHERE user_id={?}", S
::v('uid'));
706 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
707 $flags = new PlFlagSet($flags);
708 $page->assign('usage_old', $usage_old);
709 $page->assign('alias_old', $alias_old);
711 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
712 $nom_usage = strtoupper($nom_usage);
713 $page->assign('usage_req', $nom_usage);
715 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
716 S
::assert_xsrf_token();
718 // on vient de recevoir une requete, differente de l'ancien nom d'usage
719 if ($nom_usage == $nom) {
720 $page->assign('same', true
);
721 } else { // le nom de mariage est distinct du nom à l'X
722 // on calcule l'alias pour l'afficher
723 $reason = Env
::v('reason');
724 if ($reason == 'other') {
725 $reason = Env
::v('other_reason');
727 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
729 $page->assign('myusage', $myusage);
734 function handler_xnet(&$page)
736 $page->changeTpl('profile/groupesx.tpl');
737 $page->setTitle('Promo, Groupes X, Binets');
740 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
741 COUNT(e.eid) AS events, mail_domain AS lists
742 FROM groupex.membres AS m
743 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
744 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
745 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
746 $page->assign('assos', $req->fetchAllAssoc());
749 function handler_vcard(&$page, $x = null
)
757 if (substr($x, -4) == '.vcf') {
758 $x = substr($x, 0, strlen($x) - 4);
761 $vcard = new VCard($x);
762 $vcard->do_page($page);
765 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
766 $page->changeTpl('profile/admin_trombino.tpl');
767 $page->setTitle('Administration - Trombino');
768 $page->assign('uid', $uid);
771 "SELECT a.alias,promo
772 FROM auth_user_md5 AS u
773 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
774 WHERE user_id = {?}", $uid);
775 list($forlife, $promo) = $q->fetchOneRow();
779 header("Content-type: image/jpeg");
780 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
785 S
::assert_xsrf_token();
787 $data = file_get_contents($_FILES['userfile']['tmp_name']);
788 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
789 $mimetype = substr($_FILES['userfile']['type'], 6);
790 unlink($_FILES['userfile']['tmp_name']);
792 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
793 $uid, $mimetype, $data, $x, $y);
797 S
::assert_xsrf_token();
799 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
803 $page->assign('forlife', $forlife);
805 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
806 $page->setTitle('Administration - Binets');
807 $page->assign('title', 'Gestion des binets');
808 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
809 $table_editor->add_join_table('binets_ins','binet_id',true
);
810 $table_editor->describe('text','intitulé',true
);
811 $table_editor->apply($page, $action, $id);
813 function handler_admin_education(&$page, $action = 'list', $id = null
) {
814 $page->setTitle('Administration - Formations');
815 $page->assign('title', 'Gestion des formations');
816 $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id');
817 $table_editor->add_join_table('profile_education', 'eduid', true
);
818 $table_editor->add_join_table('profile_education_degree', 'eduid', true
);
819 $table_editor->describe('name', 'intitulé', true
);
820 $table_editor->describe('url', 'site web', false
);
821 $table_editor->apply($page, $action, $id);
823 function handler_admin_education_field(&$page, $action = 'list', $id = null
) {
824 $page->setTitle('Administration - Domaines de formation');
825 $page->assign('title', 'Gestion des domaines de formation');
826 $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true
);
827 $table_editor->add_join_table('profile_education', 'fieldid', true
);
828 $table_editor->describe('field', 'domaine', true
);
829 $table_editor->apply($page, $action, $id);
831 function handler_admin_education_degree(&$page, $action = 'list', $id = null
) {
832 $page->setTitle('Administration - Niveau de formation');
833 $page->assign('title', 'Gestion des niveau de formation');
834 $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id', true
);
835 $table_editor->add_join_table('profile_education_degree', 'degreeid', true
);
836 $table_editor->add_join_table('profile_education', 'degreeid', true
);
837 $table_editor->describe('degree', 'niveau', true
);
838 $table_editor->apply($page, $action, $id);
840 function handler_admin_education_degree_set(&$page, $action = 'list', $id = null
) {
841 $page->setTitle('Administration - Correspondances formations - niveau de formation');
842 $page->assign('title', 'Gestion des correspondances formations - niveau de formation');
843 $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true
);
844 $table_editor->describe('eduid', 'formation', true
);
845 $table_editor->describe('degreeid', 'niveau', true
);
846 $table_editor->apply($page, $action, $id);
848 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
849 $page->setTitle('Administration - Sections');
850 $page->assign('title', 'Gestion des sections');
851 $table_editor = new PLTableEditor('admin/sections','sections','id');
852 $table_editor->describe('text','intitulé',true
);
853 $table_editor->apply($page, $action, $id);
855 function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null
) {
856 $page->setTitle('Administration - Sous-secteurs');
857 $page->assign('title', 'Gestion des sous-secteurs');
858 $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true
);
859 $table_editor->describe('label', 'intitulé', true
);
860 $table_editor->apply($page, $action, $id);
862 function handler_admin_fonctions(&$page, $action = 'list', $id = null
) {
863 $page->setTitle('Administration - Fonctions');
864 $page->assign('title', 'Gestion des fonctions');
865 $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true
);
866 $table_editor->describe('fonction_fr', 'intitulé', true
);
867 $table_editor->describe('fonction_en', 'intitulé (ang)', true
);
868 $table_editor->describe('flags', 'titre', true
);
869 $table_editor->apply($page, $action, $id);
871 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
872 $page->setTitle('Administration - Secteurs');
873 $page->assign('title', 'Gestion des secteurs');
874 $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true
);
875 $table_editor->describe('label', 'intitulé', true
);
876 $table_editor->apply($page, $action, $id);
878 function handler_admin_networking(&$page, $action = 'list', $id = null
) {
879 $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
880 $page->assign('title', 'Gestion des types de networking');
881 $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
882 $table_editor->describe('name', 'intitulé', true
);
883 $table_editor->describe('icon', 'nom de l\'icône', false
);
884 $table_editor->describe('filter', 'filtre', true
);
885 $table_editor->describe('link', 'lien web', true
);
886 $table_editor->apply($page, $action, $id);
888 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
889 $page->setTitle('Administration - Distinctions');
890 $page->assign('title', 'Gestion des Distinctions');
891 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
892 $table_editor->describe('text', 'intitulé', true
);
893 $table_editor->describe('img', 'nom de l\'image', false
);
894 $table_editor->describe('flags', 'valider', true
);
895 $table_editor->apply($page, $action, $id);
896 if ($id && $action == 'edit') {
897 $page->changeTpl('profile/admin_decos.tpl');
901 if (Post
::v('act') == 'del') {
902 XDB
::execute('DELETE FROM profile_medals_grades
903 WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
905 foreach (Post
::v('grades', array()) as $gid=>$text) {
908 $res = XDB
::query('SELECT MAX(gid)
909 FROM profile_medals_grades
910 WHERE mid = {?}', $mid);
911 $gid = $res->fetchOneCell() +
1;
913 XDB
::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos)
914 VALUES ({?}, {?}, {?}, {?})',
915 $mid, $gid, $text, $_POST['pos']['0']);
918 XDB
::execute('UPDATE profile_medals_grades
919 SET pos={?}, text={?}
920 WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
924 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
925 $page->assign('grades', $res);
930 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: