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'),
71 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_MDP
, 'admin'),
72 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_MDP
, 'admin'),
78 function handler_fiche(&$page)
80 return $this->handler_profile($page, Env
::v('user'));
83 function handler_photo(&$page, $x = null
, $req = null
)
89 $res = XDB
::query("SELECT id, pub FROM aliases
90 LEFT JOIN photo ON(id = uid)
91 WHERE alias = {?}", $x);
92 list($uid, $photo_pub) = $res->fetchOneRow();
94 if ($req && S
::logged()) {
95 include 'validations.inc.php';
96 $myphoto = PhotoReq
::get_request($uid);
97 Header('Content-type: image/'.$myphoto->mimetype
);
101 "SELECT attachmime, attach
103 WHERE uid={?}", $uid);
105 if ((list($type, $data) = $res->fetchOneRow())
106 && ($photo_pub == 'public' || S
::logged())) {
107 Header("Content-type: image/$type");
110 Header('Content-type: image/png');
111 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
117 function handler_medal(&$page, $mid)
119 $thumb = ($mid == 'thumb');
120 $mid = $thumb ? @func_get_arg
(2) : $mid;
122 $res = XDB
::query("SELECT img
127 dirname(__FILE__
).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() :
128 dirname(__FILE__
).'/../htdocs/images/medals/' . $res->fetchOneCell();
129 $type = mime_content_type($img);
130 header("Content-Type: $type");
131 echo file_get_contents($img);
135 function handler_networking(&$page, $mid)
137 $res = XDB
::query("SELECT icon
138 FROM profile_networking_enum
139 WHERE network_type = {?}",
141 $img = dirname(__FILE__
) . '/../htdocs/images/networking/' . $res->fetchOneCell();
142 $type = mime_content_type($img);
143 header("Content-Type: $type");
144 echo file_get_contents($img);
148 function handler_photo_change(&$page)
151 $page->changeTpl('profile/trombino.tpl');
153 require_once('validations.inc.php');
155 $trombi_x = '/home/web/trombino/photos'.S
::v('promo')
156 .'/'.S
::v('forlife').'.jpg';
158 if (Env
::has('upload')) {
159 S
::assert_xsrf_token();
161 $upload = new PlUpload(S
::v('forlife'), 'photo');
162 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
163 $page->trigError('Une erreur est survenue lors du téléchargement du fichier');
165 $myphoto = new PhotoReq(S
::v('uid'), $upload);
166 if ($myphoto->isValid()) {
170 } elseif (Env
::has('trombi')) {
171 S
::assert_xsrf_token();
173 $upload = new PlUpload(S
::v('forlife'), 'photo');
174 if ($upload->copyFrom($trombi_x)) {
175 $myphoto = new PhotoReq(S
::v('uid'), $upload);
176 if ($myphoto->isValid()) {
181 } elseif (Env
::v('suppr')) {
182 S
::assert_xsrf_token();
184 XDB
::execute('DELETE FROM photo
187 XDB
::execute('DELETE FROM requests
188 WHERE user_id = {?} AND type="photo"',
190 $globals->updateNbValid();
191 } elseif (Env
::v('cancel')) {
192 S
::assert_xsrf_token();
194 $sql = XDB
::query('DELETE FROM requests
195 WHERE user_id={?} AND type="photo"',
197 $globals->updateNbValid();
200 $sql = XDB
::query('SELECT COUNT(*)
202 WHERE user_id={?} AND type="photo"',
204 $page->assign('submited', $sql->fetchOneCell());
205 $page->assign('has_trombi_x', file_exists($trombi_x));
208 function handler_profile(&$page, $x = null
)
215 require_once 'user.func.inc.php';
217 $page->changeTpl('profile/profile.tpl', SIMPLE
);
220 if (!S
::logged() || Env
::v('view') == 'public') $view = 'public';
221 if (S
::logged() && Env
::v('view') == 'ax') $view = 'ax';
223 if (is_numeric($x)) {
227 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
228 WHERE matricule={?}", $x);
229 $login = $res->fetchOneCell();
231 $login = get_user_forlife($x, S
::logged() ?
'_default_user_callback'
232 : '_silent_user_callback');
236 $user = get_not_registered_user($x, true
);
237 if ($user->total() != 1) {
240 $user = $user->next();
242 pl_redirect('marketing/public/' . $user['user_id']);
244 $user['forlife'] = $x;
246 $new = Env
::v('modif') == 'new';
247 $user = get_user_details($login, S
::v('uid'), $view);
251 S
::logger()->log('view_profile', $login);
254 $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ?
$user['nom'] : $user['nom_usage'] );
255 $page->setTitle($title);
259 $photo = 'photo/'.$user['forlife'].($new ?
'/req' : '');
261 if (!isset($user['y']) and !isset($user['x'])) {
262 list($user['x'], $user['y']) = getimagesize("images/none.png");
264 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
265 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
266 if ($user['x'] > 240) {
267 $user['y'] = (integer)($user['y']*240/$user['x']);
270 if ($user['y'] > 300) {
271 $user['x'] = (integer)($user['x']*300/$user['y']);
274 if ($user['x'] < 160) {
275 $user['y'] = (integer)($user['y']*160/$user['x']);
279 $page->assign('logged', has_user_right('private', $view));
280 if (!has_user_right($user['photo_pub'], $view)) {
284 $page->assign_by_ref('x', $user);
285 $page->assign('photo_url', $photo);
290 INNER JOIN virtual_redirect USING(vid)
291 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
292 WHERE ( redirect={?} OR redirect={?} )
293 AND alias LIKE '%@{$globals->mail->alias_dom}'",
295 $user['forlife'].'@'.$globals->mail
->domain
,
296 $user['forlife'].'@'.$globals->mail
->domain2
);
297 $page->assign('virtualalias', $res->fetchOneCell());
298 $page->assign('view', $view);
300 $page->addJsLink('close_on_esc.js');
301 header('Last-Modified: ' . date('r', strtotime($user['date'])));
304 function handler_ax(&$page, $user = null
)
306 require_once 'user.func.inc.php';
307 $user = get_user_forlife($user);
311 $res = XDB
::query('SELECT matricule_ax
312 FROM auth_user_md5 AS u
313 INNER JOIN aliases AS a ON (a.type = "a_vie" AND a.id = u.user_id)
314 WHERE a.alias = {?}', $user);
315 $mat = $res->fetchOneCell();
317 $page->kill("Le matricule AX de $user est inconnu");
319 http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
322 function handler_p_edit(&$page, $opened_tab = null
, $mode = null
)
326 // AX Synchronization
327 require_once 'synchro_ax.inc.php';
328 if (is_ax_key_missing()) {
329 $page->assign('no_private_key', true
);
331 if (Env
::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
332 ax_synchronize(S
::v('bestalias'), S
::v('uid'));
333 $page->trigSuccess('Ton profil a été synchronisé avec celui du site polytechniciens.com');
337 $page->addJsLink('ajax.js');
338 $page->addJsLink('education.js');
339 $page->addJsLink('grades.js');
340 $page->addJsLink('profile.js');
341 $page->addJsLink('jquery.autocomplete.js');
342 $wiz = new PlWizard('Profil', PlPage
::getCoreTpl('plwizard.tpl'), true
, true
);
343 $this->load('page.inc.php');
344 $wiz->addPage('ProfileGeneral', 'Général', 'general');
345 $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
346 $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
347 $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco');
348 $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
349 $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
350 $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
351 $wiz->apply($page, 'profile/edit', $opened_tab, $mode);
354 $res = XDB
::query("SELECT user_id
356 WHERE user_id = {?} AND naissance = '0000-00-00'", S
::i('uid'));
357 if ($res->numRows()) {
358 $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
359 . " la procédure de récupération de mot de passe si un jour tu le perdais");
362 $page->setTitle('Mon Profil');
365 function handler_education_js(&$page)
367 header('Content-Type: text/javascript; charset=utf-8');
368 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
369 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
370 header('Cache-Control: no-cache, must-revalidate');
371 header('Pragma: no-cache');
372 $page->changeTpl('profile/education.js.tpl', NO_SKIN
);
373 require_once "education.func.inc.php";
376 function handler_grades_js(&$page)
378 header('Content-Type: text/javascript; charset=utf-8');
379 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
380 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
381 header('Cache-Control: no-cache, must-revalidate');
382 header('Pragma: no-cache');
383 $page->changeTpl('profile/grades.js.tpl', NO_SKIN
);
384 $res = XDB
::iterator("SELECT *
385 FROM profile_medals_grades
388 while ($tmp = $res->next()) {
389 $grades[$tmp['mid']][] = $tmp;
391 $page->assign('grades', $grades);
393 $res = XDB
::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
395 ORDER BY type, text");
397 while ($tmp = $res->next()) {
398 $mlist[$tmp['type']][] = $tmp;
400 $page->assign('medal_list', $mlist);
403 function handler_ajax_address(&$page, $adid)
405 header('Content-Type: text/html; charset=utf-8');
406 $page->changeTpl('profile/adresses.address.tpl', NO_SKIN
);
407 $page->assign('i', $adid);
408 $page->assign('adr', array());
411 function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
413 header('Content-Type: text/html; charset=utf-8');
414 $page->changeTpl('profile/phone.tpl', NO_SKIN
);
415 $page->assign('prefid', $prefid);
416 $page->assign('prefname', $prefname);
417 $page->assign('telid', $telid);
418 $page->assign('tel', array());
421 function handler_ajax_edu(&$page, $eduid, $class)
423 header('Content-Type: text/html; charset=utf-8');
424 $page->changeTpl('profile/edu.tpl', NO_SKIN
);
425 $res = XDB
::iterator("SELECT id, field
426 FROM profile_education_field_enum
428 $page->assign('edu_fields', $res->fetchAllAssoc());
429 $page->assign('eduid', $eduid);
430 $page->assign('class', $class);
431 require_once "education.func.inc.php";
434 function handler_ajax_medal(&$page, $id)
436 header('Content-Type: text/html; charset=utf-8');
437 $page->changeTpl('profile/deco.medal.tpl', NO_SKIN
);
438 $page->assign('id', $id);
439 $page->assign('medal', array('valid' => 0, 'grade' => 0));
442 function handler_ajax_job(&$page, $id)
444 header('Content-Type: text/html; charset=utf-8');
445 $page->changeTpl('profile/jobs.job.tpl', NO_SKIN
);
446 $page->assign('i', $id);
447 $page->assign('job', array());
448 $page->assign('new', true
);
449 $page->assign('secteurs', XDB
::iterator("SELECT id, label
450 FROM emploi_secteur"));
451 $page->assign('fonctions', XDB
::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
456 function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
458 header('Content-Type: text/html; charset=utf-8');
459 $res = XDB
::iterator("SELECT id, label
460 FROM emploi_ss_secteur
461 WHERE secteur = {?}", $sect);
462 $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN
);
463 $page->assign('id', $id);
464 $page->assign('ssecteurs', $res);
465 $page->assign('sel', $ssect);
468 function handler_ajax_skill(&$page, $cat, $id)
470 header('Content-Type: text/html; charset=utf-8');
471 $page->changeTpl('profile/skill.skill.tpl', NO_SKIN
);
472 $page->assign('cat', $cat);
473 $page->assign('id', $id);
474 if ($cat == 'competences') {
475 $page->assign('levels', array('initié' => 'initié',
476 'bonne connaissance' => 'bonne connaissance',
477 'expert' => 'expert'));
479 $page->assign('levels', array(1 => 'connaissance basique',
480 2 => 'maîtrise des bases',
481 3 => 'maîtrise limitée',
482 4 => 'maîtrise générale',
483 5 => 'bonne maîtrise',
484 6 => 'maîtrise complète'));
488 function handler_ajax_searchname(&$page, $snid)
490 header('Content-Type: text/html; charset=utf-8');
491 $page->changeTpl('profile/general.searchname.tpl', NO_SKIN
);
492 $page->assign('i', $snid);
493 $page->assign('sn', array());
494 $page->assign('newsn', true
);
497 function handler_p_orange(&$page)
499 $page->changeTpl('profile/orange.tpl');
501 require_once 'validations.inc.php';
504 "SELECT u.promo, u.promo_sortie
505 FROM auth_user_md5 AS u
506 WHERE user_id={?}", S
::v('uid'));
508 list($promo, $promo_sortie_old) = $res->fetchOneRow();
509 $page->assign('promo_sortie_old', $promo_sortie_old);
510 $page->assign('promo', $promo);
512 if (!Env
::has('promo_sortie')) {
515 S
::assert_xsrf_token();
518 $promo_sortie = Env
::i('promo_sortie');
520 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
521 $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
523 elseif ($promo_sortie < $promo +
3) {
524 $page->trigError('Trop tôt');
526 elseif ($promo_sortie == $promo_sortie_old) {
527 $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
529 elseif ($promo_sortie == $promo +
3) {
531 "UPDATE auth_user_md5 set promo_sortie={?}
532 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
533 $page->trigSuccess('Ton statut "orange" a été supprimé.');
534 $page->assign('promo_sortie_old', $promo_sortie);
537 $page->assign('promo_sortie', $promo_sortie);
539 if (Env
::has('submit')) {
540 $myorange = new OrangeReq(S
::v('uid'),
543 $page->assign('myorange', $myorange);
548 function handler_referent(&$page, $x = null
)
550 require_once 'user.func.inc.php';
556 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
559 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
560 FROM auth_user_md5 AS u
561 INNER JOIN aliases AS a ON (u.user_id=a.id
562 AND FIND_IN_SET('bestalias', a.flags))
563 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
565 AND a1.type!='homonyme')", $x);
567 if ($res->numRows() != 1) {
571 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
573 $page->assign('prenom', $prenom);
574 $page->assign('nom', $nom);
575 $page->assign('promo', $promo);
576 $page->assign('cv', MiniWiki
::WikiToHTML($cv, true
));
577 $page->assign('bestalias', $bestalias);
578 $page->assign('adr_pro', get_user_details_pro($user_id));
580 ///// recuperations infos referent
583 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
584 $page->assign('expertise', $res->fetchOneCell());
587 $secteurs = $ss_secteurs = Array();
589 "SELECT s.label, ss.label
590 FROM mentor_secteurs AS m
591 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
592 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
593 WHERE uid = {?}", $user_id);
594 while (list($sec, $ssec) = $res->next()) {
596 $ss_secteurs[] = $ssec;
598 $page->assign_by_ref('secteurs', $secteurs);
599 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
604 FROM mentor_pays AS m
605 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
606 WHERE uid = {?}", $user_id);
607 $page->assign('pays', $res->fetchColumn());
609 $page->addJsLink('close_on_esc.js');
612 function handler_ref_search(&$page, $action = null
, $subaction = null
)
614 $wp = new PlWikiPage('Docs.Emploi');
617 $page->setTitle('Conseil Pro');
619 //recuperation des noms de secteurs
620 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
622 while (list($tmp_id, $tmp_label) = $res->next()) {
623 $secteurs[$tmp_id] = $tmp_label;
625 $page->assign_by_ref('secteurs', $secteurs);
628 $res = XDB
::query("SELECT count(*) FROM mentor");
629 $page->assign('mentors_number', $res->fetchOneCell());
631 // On vient d'un formulaire
633 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
634 $secteur_sel = XDB
::escape(Env
::v('secteur'));
635 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
636 $expertise_champ = XDB
::escape(Env
::v('expertise'));
638 if ($pays_sel != "''") {
639 $where[] = "mp.pid = $pays_sel";
641 if ($secteur_sel != "''") {
642 $where[] = "ms.secteur = $secteur_sel";
643 if ($ss_secteur_sel != "''") {
644 $where[] = "ms.ss_secteur = $ss_secteur_sel";
647 if ($expertise_champ != "''") {
648 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
652 $where = join(' AND ', $where);
654 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
655 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
656 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
658 $set->addMod('mentor', 'Référents');
659 $set->apply('referent/search', $page, $action, $subaction);
660 if ($set->count() > 100) {
661 $page->assign('recherche_trop_large', true
);
664 $page->changeTpl('profile/referent.tpl');
667 function handler_ref_sect(&$page, $sect)
669 header('Content-Type: text/html; charset=utf-8');
670 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
671 $page->assign('onchange', 'setSSecteurs()');
672 $page->assign('id', 'ssect_field');
673 $page->assign('name', 'ss_secteur');
674 $it = XDB
::iterator("SELECT id,label AS field
675 FROM emploi_ss_secteur
676 WHERE secteur = {?}", $sect);
677 $page->assign('list', $it);
680 function handler_ref_country(&$page, $sect, $ssect = '')
682 header('Content-Type: text/html; charset=utf-8');
683 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
684 $page->assign('name', 'pays_sel');
685 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
686 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
687 FROM geoloc_pays AS g
688 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
689 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
690 WHERE ms.secteur = {?} $where
692 ORDER BY pays", $sect, $ssect);
693 $page->assign('list', $it);
696 function handler_p_usage(&$page)
698 $page->changeTpl('profile/nomusage.tpl');
700 require_once 'validations.inc.php';
703 "SELECT u.nom, u.nom_usage, u.flags, e.alias
704 FROM auth_user_md5 AS u
705 LEFT JOIN aliases AS e ON(u.user_id = e.id
706 AND FIND_IN_SET('usage', e.flags))
707 WHERE user_id={?}", S
::v('uid'));
709 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
710 $flags = new PlFlagSet($flags);
711 $page->assign('usage_old', $usage_old);
712 $page->assign('alias_old', $alias_old);
714 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
715 $nom_usage = strtoupper($nom_usage);
716 $page->assign('usage_req', $nom_usage);
718 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
719 S
::assert_xsrf_token();
721 // on vient de recevoir une requete, differente de l'ancien nom d'usage
722 if ($nom_usage == $nom) {
723 $page->assign('same', true
);
724 } else { // le nom de mariage est distinct du nom à l'X
725 // on calcule l'alias pour l'afficher
726 $reason = Env
::v('reason');
727 if ($reason == 'other') {
728 $reason = Env
::v('other_reason');
730 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
732 $page->assign('myusage', $myusage);
737 function handler_xnet(&$page)
739 $page->changeTpl('profile/groupesx.tpl');
740 $page->setTitle('Promo, Groupes X, Binets');
743 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
744 COUNT(e.eid) AS events, mail_domain AS lists
745 FROM groupex.membres AS m
746 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
747 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
748 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
749 $page->assign('assos', $req->fetchAllAssoc());
752 function handler_vcard(&$page, $x = null
)
760 if (substr($x, -4) == '.vcf') {
761 $x = substr($x, 0, strlen($x) - 4);
764 $vcard = new VCard();
769 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
770 $page->changeTpl('profile/admin_trombino.tpl');
771 $page->setTitle('Administration - Trombino');
772 $page->assign('uid', $uid);
775 "SELECT a.alias,promo
776 FROM auth_user_md5 AS u
777 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
778 WHERE user_id = {?}", $uid);
779 list($forlife, $promo) = $q->fetchOneRow();
783 header("Content-type: image/jpeg");
784 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
789 S
::assert_xsrf_token();
791 $data = file_get_contents($_FILES['userfile']['tmp_name']);
792 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
793 $mimetype = substr($_FILES['userfile']['type'], 6);
794 unlink($_FILES['userfile']['tmp_name']);
796 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
797 $uid, $mimetype, $data, $x, $y);
801 S
::assert_xsrf_token();
803 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
807 $page->assign('forlife', $forlife);
809 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
810 $page->setTitle('Administration - Binets');
811 $page->assign('title', 'Gestion des binets');
812 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
813 $table_editor->add_join_table('binets_ins','binet_id',true
);
814 $table_editor->describe('text','intitulé',true
);
815 $table_editor->apply($page, $action, $id);
817 function handler_admin_education(&$page, $action = 'list', $id = null
) {
818 $page->setTitle('Administration - Formations');
819 $page->assign('title', 'Gestion des formations');
820 $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id');
821 $table_editor->add_join_table('profile_education', 'eduid', true
);
822 $table_editor->add_join_table('profile_education_degree', 'eduid', true
);
823 $table_editor->describe('name', 'intitulé', true
);
824 $table_editor->describe('url', 'site web', false
);
825 $table_editor->apply($page, $action, $id);
827 function handler_admin_education_field(&$page, $action = 'list', $id = null
) {
828 $page->setTitle('Administration - Domaines de formation');
829 $page->assign('title', 'Gestion des domaines de formation');
830 $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true
);
831 $table_editor->add_join_table('profile_education', 'fieldid', true
);
832 $table_editor->describe('field', 'domaine', true
);
833 $table_editor->apply($page, $action, $id);
835 function handler_admin_education_degree(&$page, $action = 'list', $id = null
) {
836 $page->setTitle('Administration - Niveau de formation');
837 $page->assign('title', 'Gestion des niveau de formation');
838 $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id', true
);
839 $table_editor->add_join_table('profile_education_degree', 'degreeid', true
);
840 $table_editor->add_join_table('profile_education', 'degreeid', true
);
841 $table_editor->describe('degree', 'niveau', true
);
842 $table_editor->apply($page, $action, $id);
844 function handler_admin_education_degree_set(&$page, $action = 'list', $id = null
) {
845 $page->setTitle('Administration - Correspondances formations - niveau de formation');
846 $page->assign('title', 'Gestion des correspondances formations - niveau de formation');
847 $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true
);
848 $table_editor->describe('eduid', 'formation', true
);
849 $table_editor->describe('degreeid', 'niveau', true
);
850 $table_editor->apply($page, $action, $id);
852 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
853 $page->setTitle('Administration - Sections');
854 $page->assign('title', 'Gestion des sections');
855 $table_editor = new PLTableEditor('admin/sections','sections','id');
856 $table_editor->describe('text','intitulé',true
);
857 $table_editor->apply($page, $action, $id);
859 function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null
) {
860 $page->setTitle('Administration - Sous-secteurs');
861 $page->assign('title', 'Gestion des sous-secteurs');
862 $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true
);
863 $table_editor->describe('label', 'intitulé', true
);
864 $table_editor->apply($page, $action, $id);
866 function handler_admin_fonctions(&$page, $action = 'list', $id = null
) {
867 $page->setTitle('Administration - Fonctions');
868 $page->assign('title', 'Gestion des fonctions');
869 $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true
);
870 $table_editor->describe('fonction_fr', 'intitulé', true
);
871 $table_editor->describe('fonction_en', 'intitulé (ang)', true
);
872 $table_editor->describe('flags', 'titre', true
);
873 $table_editor->apply($page, $action, $id);
875 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
876 $page->setTitle('Administration - Secteurs');
877 $page->assign('title', 'Gestion des secteurs');
878 $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true
);
879 $table_editor->describe('label', 'intitulé', true
);
880 $table_editor->apply($page, $action, $id);
882 function handler_admin_networking(&$page, $action = 'list', $id = null
) {
883 $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
884 $page->assign('title', 'Gestion des types de networking');
885 $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
886 $table_editor->describe('name', 'intitulé', true
);
887 $table_editor->describe('icon', 'nom de l\'icône', false
);
888 $table_editor->describe('filter', 'filtre', true
);
889 $table_editor->describe('link', 'lien web', true
);
890 $table_editor->apply($page, $action, $id);
892 function handler_admin_corps_enum(&$page, $action = 'list', $id = null
) {
893 $page->setTitle('Administration - Corps');
894 $page->assign('title', 'Gestion des Corps');
895 $table_editor = new PLTableEditor('admin/corps_enum', 'profile_corps_enum', 'id');
896 $table_editor->describe('name', 'intitulé', true
);
897 $table_editor->describe('abbreviation', 'abbréviation', true
);
898 $table_editor->describe('still_exists', 'existe encore ?', true
);
899 $table_editor->apply($page, $action, $id);
901 function handler_admin_corps_rank(&$page, $action = 'list', $id = null
) {
902 $page->setTitle('Administration - Grade dans les Corps');
903 $page->assign('title', 'Gestion des grade dans les Corps');
904 $table_editor = new PLTableEditor('admin/corps_rank', 'profile_corps_rank_enum', 'id');
905 $table_editor->describe('name', 'intitulé', true
);
906 $table_editor->describe('abbreviation', 'abbréviation', true
);
907 $table_editor->apply($page, $action, $id);
909 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
910 $page->setTitle('Administration - Distinctions');
911 $page->assign('title', 'Gestion des Distinctions');
912 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
913 $table_editor->describe('text', 'intitulé', true
);
914 $table_editor->describe('img', 'nom de l\'image', false
);
915 $table_editor->describe('flags', 'valider', true
);
916 $table_editor->apply($page, $action, $id);
917 if ($id && $action == 'edit') {
918 $page->changeTpl('profile/admin_decos.tpl');
922 if (Post
::v('act') == 'del') {
923 XDB
::execute('DELETE FROM profile_medals_grades
924 WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
926 foreach (Post
::v('grades', array()) as $gid=>$text) {
929 $res = XDB
::query('SELECT MAX(gid)
930 FROM profile_medals_grades
931 WHERE mid = {?}', $mid);
932 $gid = $res->fetchOneCell() +
1;
934 XDB
::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos)
935 VALUES ({?}, {?}, {?}, {?})',
936 $mid, $gid, $text, $_POST['pos']['0']);
939 XDB
::execute('UPDATE profile_medals_grades
940 SET pos={?}, text={?}
941 WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
945 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
946 $page->assign('grades', $res);
951 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: