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/medal' => $this->make_hook('ajax_medal', AUTH_COOKIE
, 'user', NO_AUTH
),
38 'profile/networking' => $this->make_hook('networking', AUTH_PUBLIC
),
39 'profile/ajax/job' => $this->make_hook('ajax_job', AUTH_COOKIE
, 'user', NO_AUTH
),
40 'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE
, 'user', NO_AUTH
),
41 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE
, 'user', NO_AUTH
),
42 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE
, 'user', NO_AUTH
),
43 'javascript/applis.js' => $this->make_hook('applis_js', AUTH_COOKIE
),
44 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE
),
45 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC
),
46 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP
),
47 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP
),
49 'referent' => $this->make_hook('referent', AUTH_COOKIE
),
50 'emploi' => $this->make_hook('ref_search', AUTH_COOKIE
),
51 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE
),
52 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE
, 'user', NO_AUTH
),
53 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE
, 'user', NO_AUTH
),
55 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE
),
57 'vcard' => $this->make_hook('vcard', AUTH_COOKIE
, 'user', NO_HTTPS
),
58 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP
, 'admin'),
59 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP
, 'admin'),
60 'admin/formations' => $this->make_hook('admin_formations', AUTH_MDP
, 'admin'),
61 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP
, 'admin'),
62 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP
, 'admin'),
63 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP
, 'admin'),
64 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP
, 'admin'),
65 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP
, 'admin'),
66 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP
, 'admin'),
72 function handler_fiche(&$page)
74 return $this->handler_profile($page, Env
::v('user'));
77 function handler_photo(&$page, $x = null
, $req = null
)
83 $res = XDB
::query("SELECT id, pub FROM aliases
84 LEFT JOIN photo ON(id = uid)
85 WHERE alias = {?}", $x);
86 list($uid, $photo_pub) = $res->fetchOneRow();
88 if ($req && S
::logged()) {
89 include 'validations.inc.php';
90 $myphoto = PhotoReq
::get_request($uid);
91 Header('Content-type: image/'.$myphoto->mimetype
);
95 "SELECT attachmime, attach
97 WHERE uid={?}", $uid);
99 if ((list($type, $data) = $res->fetchOneRow())
100 && ($photo_pub == 'public' || S
::logged())) {
101 Header("Content-type: image/$type");
104 Header('Content-type: image/png');
105 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
111 function handler_medal(&$page, $mid)
113 $thumb = ($mid == 'thumb');
114 $mid = $thumb ? @func_get_arg
(2) : $mid;
116 $res = XDB
::query("SELECT img
121 dirname(__FILE__
).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() :
122 dirname(__FILE__
).'/../htdocs/images/medals/' . $res->fetchOneCell();
123 $type = mime_content_type($img);
124 header("Content-Type: $type");
125 echo file_get_contents($img);
129 function handler_networking(&$page, $mid)
131 $res = XDB
::query("SELECT icon
132 FROM profile_networking_enum
133 WHERE network_type = {?}",
135 $img = dirname(__FILE__
) . '/../htdocs/images/networking/' . $res->fetchOneCell();
136 $type = mime_content_type($img);
137 header("Content-Type: $type");
138 echo file_get_contents($img);
142 function handler_photo_change(&$page)
145 $page->changeTpl('profile/trombino.tpl');
147 require_once('validations.inc.php');
149 $trombi_x = '/home/web/trombino/photos'.S
::v('promo')
150 .'/'.S
::v('forlife').'.jpg';
152 if (Env
::has('upload')) {
153 S
::assert_xsrf_token();
155 $upload = new PlUpload(S
::v('forlife'), 'photo');
156 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
157 $page->trigError('Une erreur est survenue lors du téléchargement du fichier');
159 $myphoto = new PhotoReq(S
::v('uid'), $upload);
160 if ($myphoto->isValid()) {
164 } elseif (Env
::has('trombi')) {
165 S
::assert_xsrf_token();
167 $upload = new PlUpload(S
::v('forlife'), 'photo');
168 if ($upload->copyFrom($trombi_x)) {
169 $myphoto = new PhotoReq(S
::v('uid'), $upload);
170 if ($myphoto->isValid()) {
175 } elseif (Env
::v('suppr')) {
176 S
::assert_xsrf_token();
178 XDB
::execute('DELETE FROM photo
181 XDB
::execute('DELETE FROM requests
182 WHERE user_id = {?} AND type="photo"',
184 $globals->updateNbValid();
185 } elseif (Env
::v('cancel')) {
186 S
::assert_xsrf_token();
188 $sql = XDB
::query('DELETE FROM requests
189 WHERE user_id={?} AND type="photo"',
191 $globals->updateNbValid();
194 $sql = XDB
::query('SELECT COUNT(*)
196 WHERE user_id={?} AND type="photo"',
198 $page->assign('submited', $sql->fetchOneCell());
199 $page->assign('has_trombi_x', file_exists($trombi_x));
202 function handler_profile(&$page, $x = null
)
209 require_once 'user.func.inc.php';
211 $page->changeTpl('profile/profile.tpl', SIMPLE
);
214 if (!S
::logged() || Env
::v('view') == 'public') $view = 'public';
215 if (S
::logged() && Env
::v('view') == 'ax') $view = 'ax';
217 if (is_numeric($x)) {
221 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
222 WHERE matricule={?}", $x);
223 $login = $res->fetchOneCell();
225 $login = get_user_forlife($x, S
::logged() ?
'_default_user_callback'
226 : '_silent_user_callback');
230 $user = get_not_registered_user($x, true
);
231 if ($user->total() != 1) {
234 $user = $user->next();
236 pl_redirect('marketing/public/' . $user['user_id']);
238 $user['forlife'] = $x;
240 $new = Env
::v('modif') == 'new';
241 $user = get_user_details($login, S
::v('uid'), $view);
245 S
::logger()->log('view_profile', $login);
248 $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ?
$user['nom'] : $user['nom_usage'] );
249 $page->setTitle($title);
253 $photo = 'photo/'.$user['forlife'].($new ?
'/req' : '');
255 if (!isset($user['y']) and !isset($user['x'])) {
256 list($user['x'], $user['y']) = getimagesize("images/none.png");
258 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
259 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
260 if ($user['x'] > 240) {
261 $user['y'] = (integer)($user['y']*240/$user['x']);
264 if ($user['y'] > 300) {
265 $user['x'] = (integer)($user['x']*300/$user['y']);
268 if ($user['x'] < 160) {
269 $user['y'] = (integer)($user['y']*160/$user['x']);
273 $page->assign('logged', has_user_right('private', $view));
274 if (!has_user_right($user['photo_pub'], $view)) {
278 $page->assign_by_ref('x', $user);
279 $page->assign('photo_url', $photo);
284 INNER JOIN virtual_redirect USING(vid)
285 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
286 WHERE ( redirect={?} OR redirect={?} )
287 AND alias LIKE '%@{$globals->mail->alias_dom}'",
289 $user['forlife'].'@'.$globals->mail
->domain
,
290 $user['forlife'].'@'.$globals->mail
->domain2
);
291 $page->assign('virtualalias', $res->fetchOneCell());
292 $page->assign('view', $view);
294 $page->addJsLink('close_on_esc.js');
295 header('Last-Modified: ' . date('r', strtotime($user['date'])));
298 function handler_ax(&$page, $user = null
)
300 require_once 'user.func.inc.php';
301 $user = get_user_forlife($user);
305 $res = XDB
::query('SELECT matricule_ax
306 FROM auth_user_md5 AS u
307 INNER JOIN aliases AS a ON (a.type = "a_vie" AND a.id = u.user_id)
308 WHERE a.alias = {?}', $user);
309 $mat = $res->fetchOneCell();
311 $page->kill("Le matricule AX de $user est inconnu");
313 http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
316 function handler_p_edit(&$page, $opened_tab = null
, $mode = null
)
320 // AX Synchronization
321 require_once 'synchro_ax.inc.php';
322 if (is_ax_key_missing()) {
323 $page->assign('no_private_key', true
);
325 if (Env
::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
326 ax_synchronize(S
::v('bestalias'), S
::v('uid'));
327 $page->trigSuccess('Ton profil a été synchronisé avec celui du site polytechniciens.com');
331 $page->addJsLink('ajax.js');
332 $page->addJsLink('applis.js');
333 $page->addJsLink('grades.js');
334 $page->addJsLink('profile.js');
335 $page->addJsLink('jquery.autocomplete.js');
336 $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true
, true
);
337 require_once dirname(__FILE__
) . '/profile/page.inc.php';
338 $wiz->addPage('ProfileGeneral', 'Général', 'general');
339 $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
340 $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
341 $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco');
342 $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
343 $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
344 $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
345 $wiz->apply($page, 'profile/edit', $opened_tab, $mode);
348 $res = XDB
::query("SELECT user_id
350 WHERE user_id = {?} AND naissance = '0000-00-00'", S
::i('uid'));
351 if ($res->numRows()) {
352 $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
353 . " la procédure de récupération de mot de passe si un jour tu le perdais");
356 $page->setTitle('Mon Profil');
359 function handler_applis_js(&$page)
361 header('Content-Type: text/javascript; charset=utf-8');
362 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
363 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
364 header('Cache-Control: no-cache, must-revalidate');
365 header('Pragma: no-cache');
366 $page->changeTpl('profile/applis.js.tpl', NO_SKIN
);
367 require_once "applis.func.inc.php";
370 function handler_grades_js(&$page)
372 header('Content-Type: text/javascript; charset=utf-8');
373 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
374 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
375 header('Cache-Control: no-cache, must-revalidate');
376 header('Pragma: no-cache');
377 $page->changeTpl('profile/grades.js.tpl', NO_SKIN
);
378 $res = XDB
::iterator("SELECT *
379 FROM profile_medals_grades
382 while ($tmp = $res->next()) {
383 $grades[$tmp['mid']][] = $tmp;
385 $page->assign('grades', $grades);
387 $res = XDB
::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
389 ORDER BY type, text");
391 while ($tmp = $res->next()) {
392 $mlist[$tmp['type']][] = $tmp;
394 $page->assign('medal_list', $mlist);
397 function handler_ajax_address(&$page, $adid)
399 header('Content-Type: text/html; charset=utf-8');
400 $page->changeTpl('profile/adresses.address.tpl', NO_SKIN
);
401 $page->assign('i', $adid);
402 $page->assign('adr', array());
405 function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
407 header('Content-Type: text/html; charset=utf-8');
408 $page->changeTpl('profile/phone.tpl', NO_SKIN
);
409 $page->assign('prefid', $prefid);
410 $page->assign('prefname', $prefname);
411 $page->assign('telid', $telid);
412 $page->assign('tel', array());
415 function handler_ajax_medal(&$page, $id)
417 header('Content-Type: text/html; charset=utf-8');
418 $page->changeTpl('profile/deco.medal.tpl', NO_SKIN
);
419 $page->assign('id', $id);
420 $page->assign('medal', array('valid' => 0, 'grade' => 0));
423 function handler_ajax_job(&$page, $id)
425 header('Content-Type: text/html; charset=utf-8');
426 $page->changeTpl('profile/jobs.job.tpl', NO_SKIN
);
427 $page->assign('i', $id);
428 $page->assign('job', array());
429 $page->assign('new', true
);
430 $page->assign('secteurs', XDB
::iterator("SELECT id, label
431 FROM emploi_secteur"));
432 $page->assign('fonctions', XDB
::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
437 function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
439 header('Content-Type: text/html; charset=utf-8');
440 $res = XDB
::iterator("SELECT id, label
441 FROM emploi_ss_secteur
442 WHERE secteur = {?}", $sect);
443 $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN
);
444 $page->assign('id', $id);
445 $page->assign('ssecteurs', $res);
446 $page->assign('sel', $ssect);
449 function handler_ajax_skill(&$page, $cat, $id)
451 header('Content-Type: text/html; charset=utf-8');
452 $page->changeTpl('profile/skill.skill.tpl', NO_SKIN
);
453 $page->assign('cat', $cat);
454 $page->assign('id', $id);
455 if ($cat == 'competences') {
456 $page->assign('levels', array('initié' => 'initié',
457 'bonne connaissance' => 'bonne connaissance',
458 'expert' => 'expert'));
460 $page->assign('levels', array(1 => 'connaissance basique',
461 2 => 'maîtrise des bases',
462 3 => 'maîtrise limitée',
463 4 => 'maîtrise générale',
464 5 => 'bonne maîtrise',
465 6 => 'maîtrise complète'));
469 function handler_ajax_searchname(&$page, $snid)
471 header('Content-Type: text/html; charset=utf-8');
472 $page->changeTpl('profile/general.searchname.tpl', NO_SKIN
);
473 $page->assign('i', $snid);
474 $page->assign('sn', array());
475 $page->assign('newsn', true
);
478 function handler_p_orange(&$page)
480 $page->changeTpl('profile/orange.tpl');
482 require_once 'validations.inc.php';
485 "SELECT u.promo, u.promo_sortie
486 FROM auth_user_md5 AS u
487 WHERE user_id={?}", S
::v('uid'));
489 list($promo, $promo_sortie_old) = $res->fetchOneRow();
490 $page->assign('promo_sortie_old', $promo_sortie_old);
491 $page->assign('promo', $promo);
493 if (!Env
::has('promo_sortie')) {
496 S
::assert_xsrf_token();
499 $promo_sortie = Env
::i('promo_sortie');
501 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
502 $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
504 elseif ($promo_sortie < $promo +
3) {
505 $page->trigError('Trop tôt');
507 elseif ($promo_sortie == $promo_sortie_old) {
508 $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
510 elseif ($promo_sortie == $promo +
3) {
512 "UPDATE auth_user_md5 set promo_sortie={?}
513 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
514 $page->trigSuccess('Ton statut "orange" a été supprimé.');
515 $page->assign('promo_sortie_old', $promo_sortie);
518 $page->assign('promo_sortie', $promo_sortie);
520 if (Env
::has('submit')) {
521 $myorange = new OrangeReq(S
::v('uid'),
524 $page->assign('myorange', $myorange);
529 function handler_referent(&$page, $x = null
)
531 require_once 'user.func.inc.php';
537 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
540 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
541 FROM auth_user_md5 AS u
542 INNER JOIN aliases AS a ON (u.user_id=a.id
543 AND FIND_IN_SET('bestalias', a.flags))
544 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
546 AND a1.type!='homonyme')", $x);
548 if ($res->numRows() != 1) {
552 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
554 $page->assign('prenom', $prenom);
555 $page->assign('nom', $nom);
556 $page->assign('promo', $promo);
557 $page->assign('cv', MiniWiki
::WikiToHTML($cv, true
));
558 $page->assign('bestalias', $bestalias);
559 $page->assign('adr_pro', get_user_details_pro($user_id));
561 ///// recuperations infos referent
564 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
565 $page->assign('expertise', $res->fetchOneCell());
568 $secteurs = $ss_secteurs = Array();
570 "SELECT s.label, ss.label
571 FROM mentor_secteurs AS m
572 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
573 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
574 WHERE uid = {?}", $user_id);
575 while (list($sec, $ssec) = $res->next()) {
577 $ss_secteurs[] = $ssec;
579 $page->assign_by_ref('secteurs', $secteurs);
580 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
585 FROM mentor_pays AS m
586 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
587 WHERE uid = {?}", $user_id);
588 $page->assign('pays', $res->fetchColumn());
590 $page->addJsLink('close_on_esc.js');
593 function handler_ref_search(&$page, $action = null
, $subaction = null
)
595 $wp = new PlWikiPage('Docs.Emploi');
598 $page->setTitle('Conseil Pro');
600 //recuperation des noms de secteurs
601 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
603 while (list($tmp_id, $tmp_label) = $res->next()) {
604 $secteurs[$tmp_id] = $tmp_label;
606 $page->assign_by_ref('secteurs', $secteurs);
609 $res = XDB
::query("SELECT count(*) FROM mentor");
610 $page->assign('mentors_number', $res->fetchOneCell());
612 // On vient d'un formulaire
614 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
615 $secteur_sel = XDB
::escape(Env
::v('secteur'));
616 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
617 $expertise_champ = XDB
::escape(Env
::v('expertise'));
619 if ($pays_sel != "''") {
620 $where[] = "mp.pid = $pays_sel";
622 if ($secteur_sel != "''") {
623 $where[] = "ms.secteur = $secteur_sel";
624 if ($ss_secteur_sel != "''") {
625 $where[] = "ms.ss_secteur = $ss_secteur_sel";
628 if ($expertise_champ != "''") {
629 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
633 $where = join(' AND ', $where);
635 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
636 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
637 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
639 $set->addMod('mentor', 'Référents');
640 $set->apply('referent/search', $page, $action, $subaction);
641 if ($set->count() > 100) {
642 $page->assign('recherche_trop_large', true
);
645 $page->changeTpl('profile/referent.tpl');
648 function handler_ref_sect(&$page, $sect)
650 header('Content-Type: text/html; charset=utf-8');
651 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
652 $page->assign('onchange', 'setSSecteurs()');
653 $page->assign('id', 'ssect_field');
654 $page->assign('name', 'ss_secteur');
655 $it = XDB
::iterator("SELECT id,label AS field
656 FROM emploi_ss_secteur
657 WHERE secteur = {?}", $sect);
658 $page->assign('list', $it);
661 function handler_ref_country(&$page, $sect, $ssect = '')
663 header('Content-Type: text/html; charset=utf-8');
664 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
665 $page->assign('name', 'pays_sel');
666 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
667 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
668 FROM geoloc_pays AS g
669 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
670 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
671 WHERE ms.secteur = {?} $where
673 ORDER BY pays", $sect, $ssect);
674 $page->assign('list', $it);
677 function handler_p_usage(&$page)
679 $page->changeTpl('profile/nomusage.tpl');
681 require_once 'validations.inc.php';
684 "SELECT u.nom, u.nom_usage, u.flags, e.alias
685 FROM auth_user_md5 AS u
686 LEFT JOIN aliases AS e ON(u.user_id = e.id
687 AND FIND_IN_SET('usage', e.flags))
688 WHERE user_id={?}", S
::v('uid'));
690 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
691 $flags = new PlFlagSet($flags);
692 $page->assign('usage_old', $usage_old);
693 $page->assign('alias_old', $alias_old);
695 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
696 $nom_usage = strtoupper($nom_usage);
697 $page->assign('usage_req', $nom_usage);
699 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
700 S
::assert_xsrf_token();
702 // on vient de recevoir une requete, differente de l'ancien nom d'usage
703 if ($nom_usage == $nom) {
704 $page->assign('same', true
);
705 } else { // le nom de mariage est distinct du nom à l'X
706 // on calcule l'alias pour l'afficher
707 $reason = Env
::v('reason');
708 if ($reason == 'other') {
709 $reason = Env
::v('other_reason');
711 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
713 $page->assign('myusage', $myusage);
718 function handler_xnet(&$page)
720 $page->changeTpl('profile/groupesx.tpl');
721 $page->setTitle('Promo, Groupes X, Binets');
724 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
725 COUNT(e.eid) AS events, mail_domain AS lists
726 FROM groupex.membres AS m
727 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
728 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
729 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
730 $page->assign('assos', $req->fetchAllAssoc());
733 function handler_vcard(&$page, $x = null
)
741 if (substr($x, -4) == '.vcf') {
742 $x = substr($x, 0, strlen($x) - 4);
745 $vcard = new VCard($x);
746 $vcard->do_page($page);
749 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
750 $page->changeTpl('profile/admin_trombino.tpl');
751 $page->setTitle('Administration - Trombino');
752 $page->assign('uid', $uid);
755 "SELECT a.alias,promo
756 FROM auth_user_md5 AS u
757 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
758 WHERE user_id = {?}", $uid);
759 list($forlife, $promo) = $q->fetchOneRow();
763 header("Content-type: image/jpeg");
764 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
769 S
::assert_xsrf_token();
771 $data = file_get_contents($_FILES['userfile']['tmp_name']);
772 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
773 $mimetype = substr($_FILES['userfile']['type'], 6);
774 unlink($_FILES['userfile']['tmp_name']);
776 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
777 $uid, $mimetype, $data, $x, $y);
781 S
::assert_xsrf_token();
783 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
787 $page->assign('forlife', $forlife);
789 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
790 $page->setTitle('Administration - Binets');
791 $page->assign('title', 'Gestion des binets');
792 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
793 $table_editor->add_join_table('binets_ins','binet_id',true
);
794 $table_editor->describe('text','intitulé',true
);
795 $table_editor->apply($page, $action, $id);
797 function handler_admin_formations(&$page, $action = 'list', $id = null
) {
798 $page->setTitle('Administration - Formations');
799 $page->assign('title', 'Gestion des formations');
800 $table_editor = new PLTableEditor('admin/formations','applis_def','id');
801 $table_editor->add_join_table('applis_ins','aid',true
);
802 $table_editor->describe('text','intitulé',true
);
803 $table_editor->describe('url','site web',false
);
804 $table_editor->apply($page, $action, $id);
806 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
807 $page->setTitle('Administration - Sections');
808 $page->assign('title', 'Gestion des sections');
809 $table_editor = new PLTableEditor('admin/sections','sections','id');
810 $table_editor->describe('text','intitulé',true
);
811 $table_editor->apply($page, $action, $id);
813 function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null
) {
814 $page->setTitle('Administration - Sous-secteurs');
815 $page->assign('title', 'Gestion des sous-secteurs');
816 $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true
);
817 $table_editor->describe('label', 'intitulé', true
);
818 $table_editor->apply($page, $action, $id);
820 function handler_admin_fonctions(&$page, $action = 'list', $id = null
) {
821 $page->setTitle('Administration - Fonctions');
822 $page->assign('title', 'Gestion des fonctions');
823 $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true
);
824 $table_editor->describe('fonction_fr', 'intitulé', true
);
825 $table_editor->describe('fonction_en', 'intitulé (ang)', true
);
826 $table_editor->describe('flags', 'titre', true
);
827 $table_editor->apply($page, $action, $id);
829 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
830 $page->setTitle('Administration - Secteurs');
831 $page->assign('title', 'Gestion des secteurs');
832 $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true
);
833 $table_editor->describe('label', 'intitulé', true
);
834 $table_editor->apply($page, $action, $id);
836 function handler_admin_networking(&$page, $action = 'list', $id = null
) {
837 $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
838 $page->assign('title', 'Gestion des types de networking');
839 $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
840 $table_editor->describe('name', 'intitulé', true
);
841 $table_editor->describe('icon', 'nom de l\'icône', false
);
842 $table_editor->describe('filter', 'filtre', true
);
843 $table_editor->describe('link', 'lien web', true
);
844 $table_editor->apply($page, $action, $id);
846 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
847 $page->setTitle('Administration - Distinctions');
848 $page->assign('title', 'Gestion des Distinctions');
849 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
850 $table_editor->describe('text', 'intitulé', true
);
851 $table_editor->describe('img', 'nom de l\'image', false
);
852 $table_editor->describe('flags', 'valider', true
);
853 $table_editor->apply($page, $action, $id);
854 if ($id && $action == 'edit') {
855 $page->changeTpl('profile/admin_decos.tpl');
859 if (Post
::v('act') == 'del') {
860 XDB
::execute('DELETE FROM profile_medals_grades
861 WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
863 foreach (Post
::v('grades', array()) as $gid=>$text) {
866 $res = XDB
::query('SELECT MAX(gid)
867 FROM profile_medals_grades
868 WHERE mid = {?}', $mid);
869 $gid = $res->fetchOneCell() +
1;
871 XDB
::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos)
872 VALUES ({?}, {?}, {?}, {?})',
873 $mid, $gid, $text, $_POST['pos']['0']);
876 XDB
::execute('UPDATE profile_medals_grades
877 SET pos={?}, text={?}
878 WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
882 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
883 $page->assign('grades', $res);
888 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: