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'),
67 'admin/phones_format_display' => $this->make_hook('admin_phones_format_display', AUTH_MDP
, 'admin'),
73 function handler_fiche(&$page)
75 return $this->handler_profile($page, Env
::v('user'));
78 function handler_photo(&$page, $x = null
, $req = null
)
84 $res = XDB
::query("SELECT id, pub FROM aliases
85 LEFT JOIN photo ON(id = uid)
86 WHERE alias = {?}", $x);
87 list($uid, $photo_pub) = $res->fetchOneRow();
89 if ($req && S
::logged()) {
90 include 'validations.inc.php';
91 $myphoto = PhotoReq
::get_request($uid);
92 Header('Content-type: image/'.$myphoto->mimetype
);
96 "SELECT attachmime, attach
98 WHERE uid={?}", $uid);
100 if ((list($type, $data) = $res->fetchOneRow())
101 && ($photo_pub == 'public' || S
::logged())) {
102 Header("Content-type: image/$type");
105 Header('Content-type: image/png');
106 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
112 function handler_medal(&$page, $mid)
114 $thumb = ($mid == 'thumb');
115 $mid = $thumb ? @func_get_arg
(2) : $mid;
117 $res = XDB
::query("SELECT img
122 dirname(__FILE__
).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() :
123 dirname(__FILE__
).'/../htdocs/images/medals/' . $res->fetchOneCell();
124 $type = mime_content_type($img);
125 header("Content-Type: $type");
126 echo file_get_contents($img);
130 function handler_networking(&$page, $mid)
132 $res = XDB
::query("SELECT icon
133 FROM profile_networking_enum
134 WHERE network_type = {?}",
136 $img = dirname(__FILE__
) . '/../htdocs/images/networking/' . $res->fetchOneCell();
137 $type = mime_content_type($img);
138 header("Content-Type: $type");
139 echo file_get_contents($img);
143 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 $upload = new PlUpload(S
::v('forlife'), 'photo');
154 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
155 $page->trigError('Une erreur est survenue lors du téléchargement du fichier');
157 $myphoto = new PhotoReq(S
::v('uid'), $upload);
158 if ($myphoto->isValid()) {
162 } elseif (Env
::has('trombi')) {
163 $upload = new PlUpload(S
::v('forlife'), 'photo');
164 if ($upload->copyFrom($trombi_x)) {
165 $myphoto = new PhotoReq(S
::v('uid'), $upload);
166 if ($myphoto->isValid()) {
171 } elseif (Env
::v('suppr')) {
172 XDB
::execute('DELETE FROM photo
175 XDB
::execute('DELETE FROM requests
176 WHERE user_id = {?} AND type="photo"',
179 } elseif (Env
::v('cancel')) {
180 $sql = XDB
::query('DELETE FROM requests
181 WHERE user_id={?} AND type="photo"',
186 $sql = XDB
::query('SELECT COUNT(*)
188 WHERE user_id={?} AND type="photo"',
190 $page->assign('submited', $sql->fetchOneCell());
191 $page->assign('has_trombi_x', file_exists($trombi_x));
194 function handler_profile(&$page, $x = null
)
201 require_once 'user.func.inc.php';
203 $page->changeTpl('profile/profile.tpl', SIMPLE
);
206 if (!S
::logged() || Env
::v('view') == 'public') $view = 'public';
207 if (S
::logged() && Env
::v('view') == 'ax') $view = 'ax';
209 if (is_numeric($x)) {
213 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
214 WHERE matricule={?}", $x);
215 $login = $res->fetchOneCell();
217 $login = get_user_forlife($x, S
::logged() ?
'_default_user_callback'
218 : '_silent_user_callback');
222 $user = get_not_registered_user($x, true
);
223 if ($user->total() != 1) {
226 $user = $user->next();
228 pl_redirect('marketing/public/' . $user['user_id']);
230 $user['forlife'] = $x;
232 $new = Env
::v('modif') == 'new';
233 $user = get_user_details($login, S
::v('uid'), $view);
237 $_SESSION['log']->log('view_profile', $login);
240 $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ?
$user['nom'] : $user['nom_usage'] );
241 $page->assign('xorg_title', $title);
245 $photo = 'photo/'.$user['forlife'].($new ?
'/req' : '');
247 if (!isset($user['y']) and !isset($user['x'])) {
248 list($user['x'], $user['y']) = getimagesize("images/none.png");
250 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
251 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
252 if ($user['x'] > 240) {
253 $user['y'] = (integer)($user['y']*240/$user['x']);
256 if ($user['y'] > 300) {
257 $user['x'] = (integer)($user['x']*300/$user['y']);
260 if ($user['x'] < 160) {
261 $user['y'] = (integer)($user['y']*160/$user['x']);
265 $page->assign('logged', has_user_right('private', $view));
266 if (!has_user_right($user['photo_pub'], $view)) {
270 $page->assign_by_ref('x', $user);
271 $page->assign('photo_url', $photo);
276 INNER JOIN virtual_redirect USING(vid)
277 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
278 WHERE ( redirect={?} OR redirect={?} )
279 AND alias LIKE '%@{$globals->mail->alias_dom}'",
281 $user['forlife'].'@'.$globals->mail
->domain
,
282 $user['forlife'].'@'.$globals->mail
->domain2
);
283 $page->assign('virtualalias', $res->fetchOneCell());
284 $page->assign('view', $view);
286 $page->addJsLink('close_on_esc.js');
287 header('Last-Modified: ' . date('r', strtotime($user['date'])));
290 function handler_ax(&$page, $user = null
)
292 require_once 'user.func.inc.php';
293 $user = get_user_forlife($user);
297 $res = XDB
::query('SELECT matricule_ax
298 FROM auth_user_md5 AS u
299 INNER JOIN aliases AS a ON (a.type = "a_vie" AND a.id = u.user_id)
300 WHERE a.alias = {?}', $user);
301 $mat = $res->fetchOneCell();
303 $page->kill("Le matricule AX de $user est inconnu");
305 http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
308 function handler_p_edit(&$page, $opened_tab = null
, $mode = null
)
312 // AX Synchronization
313 require_once 'synchro_ax.inc.php';
314 if (is_ax_key_missing()) {
315 $page->assign('no_private_key', true
);
317 if (Env
::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
318 ax_synchronize(S
::v('bestalias'), S
::v('uid'));
319 $page->trigSuccess('Ton profil a été synchronisé avec celui du site polytechniciens.com');
323 $page->addJsLink('ajax.js');
324 $page->addJsLink('applis.js');
325 $page->addJsLink('grades.js');
326 $page->addJsLink('profile.js');
327 $page->addJsLink('jquery.autocomplete.js');
328 $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true
, true
);
329 require_once dirname(__FILE__
) . '/profile/page.inc.php';
330 $wiz->addPage('ProfileGeneral', 'Général', 'general');
331 $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
332 $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
333 $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco');
334 $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
335 $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
336 $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
337 $wiz->apply($page, 'profile/edit', $opened_tab, $mode);
340 $res = XDB
::query("SELECT user_id
342 WHERE user_id = {?} AND naissance = '0000-00-00'", S
::i('uid'));
343 if ($res->numRows()) {
344 $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
345 . " la procédure de récupération de mot de passe si un jour tu le perdais");
348 $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
351 function handler_applis_js(&$page)
353 header('Content-Type: text/javascript; charset=utf-8');
354 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
355 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
356 header('Cache-Control: no-cache, must-revalidate');
357 header('Pragma: no-cache');
358 $page->changeTpl('profile/applis.js.tpl', NO_SKIN
);
359 require_once "applis.func.inc.php";
362 function handler_grades_js(&$page)
364 header('Content-Type: text/javascript; charset=utf-8');
365 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
366 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
367 header('Cache-Control: no-cache, must-revalidate');
368 header('Pragma: no-cache');
369 $page->changeTpl('profile/grades.js.tpl', NO_SKIN
);
370 $res = XDB
::iterator("SELECT *
371 FROM profile_medals_grades
374 while ($tmp = $res->next()) {
375 $grades[$tmp['mid']][] = $tmp;
377 $page->assign('grades', $grades);
379 $res = XDB
::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
381 ORDER BY type, text");
383 while ($tmp = $res->next()) {
384 $mlist[$tmp['type']][] = $tmp;
386 $page->assign('medal_list', $mlist);
389 function handler_ajax_address(&$page, $adid)
391 header('Content-Type: text/html; charset=utf-8');
392 $page->changeTpl('profile/adresses.address.tpl', NO_SKIN
);
393 $page->assign('i', $adid);
394 $page->assign('adr', array());
397 function handler_ajax_tel(&$page, $adid, $telid)
399 header('Content-Type: text/html; charset=utf-8');
400 $page->changeTpl('profile/adresses.tel.tpl', NO_SKIN
);
401 $page->assign('i', $adid);
402 $page->assign('adid', "addresses_$adid");
403 $page->assign('adpref', "addresses[$adid]");
404 $page->assign('t', $telid);
405 $page->assign('tel', array());
408 function handler_ajax_medal(&$page, $id)
410 header('Content-Type: text/html; charset=utf-8');
411 $page->changeTpl('profile/deco.medal.tpl', NO_SKIN
);
412 $page->assign('id', $id);
413 $page->assign('medal', array('valid' => 0, 'grade' => 0));
416 function handler_ajax_job(&$page, $id)
418 header('Content-Type: text/html; charset=utf-8');
419 $page->changeTpl('profile/jobs.job.tpl', NO_SKIN
);
420 $page->assign('i', $id);
421 $page->assign('job', array());
422 $page->assign('new', true
);
423 $page->assign('secteurs', XDB
::iterator("SELECT id, label
424 FROM emploi_secteur"));
425 $page->assign('fonctions', XDB
::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
430 function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
432 header('Content-Type: text/html; charset=utf-8');
433 $res = XDB
::iterator("SELECT id, label
434 FROM emploi_ss_secteur
435 WHERE secteur = {?}", $sect);
436 $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN
);
437 $page->assign('id', $id);
438 $page->assign('ssecteurs', $res);
439 $page->assign('sel', $ssect);
442 function handler_ajax_skill(&$page, $cat, $id)
444 header('Content-Type: text/html; charset=utf-8');
445 $page->changeTpl('profile/skill.skill.tpl', NO_SKIN
);
446 $page->assign('cat', $cat);
447 $page->assign('id', $id);
448 if ($cat == 'competences') {
449 $page->assign('levels', array('initié' => 'initié',
450 'bonne connaissance' => 'bonne connaissance',
451 'expert' => 'expert'));
453 $page->assign('levels', array(1 => 'connaissance basique',
454 2 => 'maîtrise des bases',
455 3 => 'maîtrise limitée',
456 4 => 'maîtrise générale',
457 5 => 'bonne maîtrise',
458 6 => 'maîtrise complète'));
462 function handler_ajax_searchname(&$page, $snid)
464 header('Content-Type: text/html; charset=utf-8');
465 $page->changeTpl('profile/general.searchname.tpl', NO_SKIN
);
466 $page->assign('i', $snid);
467 $page->assign('sn', array());
468 $page->assign('newsn', true
);
471 function handler_p_orange(&$page)
473 $page->changeTpl('profile/orange.tpl');
475 require_once 'validations.inc.php';
476 require_once 'xorg.misc.inc.php';
479 "SELECT u.promo, u.promo_sortie
480 FROM auth_user_md5 AS u
481 WHERE user_id={?}", S
::v('uid'));
483 list($promo, $promo_sortie_old) = $res->fetchOneRow();
484 $page->assign('promo_sortie_old', $promo_sortie_old);
485 $page->assign('promo', $promo);
487 if (!Env
::has('promo_sortie')) {
491 $promo_sortie = Env
::i('promo_sortie');
493 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
494 $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
496 elseif ($promo_sortie < $promo +
3) {
497 $page->trigError('Trop tôt');
499 elseif ($promo_sortie == $promo_sortie_old) {
500 $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
502 elseif ($promo_sortie == $promo +
3) {
504 "UPDATE auth_user_md5 set promo_sortie={?}
505 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
506 $page->trigSuccess('Ton statut "orange" a été supprimé.');
507 $page->assign('promo_sortie_old', $promo_sortie);
510 $page->assign('promo_sortie', $promo_sortie);
512 if (Env
::has('submit')) {
513 $myorange = new OrangeReq(S
::v('uid'),
516 $page->assign('myorange', $myorange);
521 function handler_referent(&$page, $x = null
)
523 require_once 'user.func.inc.php';
529 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
532 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
533 FROM auth_user_md5 AS u
534 INNER JOIN aliases AS a ON (u.user_id=a.id
535 AND FIND_IN_SET('bestalias', a.flags))
536 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
538 AND a1.type!='homonyme')", $x);
540 if ($res->numRows() != 1) {
544 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
546 $page->assign('prenom', $prenom);
547 $page->assign('nom', $nom);
548 $page->assign('promo', $promo);
549 $page->assign('cv', MiniWiki
::WikiToHTML($cv, true
));
550 $page->assign('bestalias', $bestalias);
551 $page->assign('adr_pro', get_user_details_pro($user_id));
553 ///// recuperations infos referent
556 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
557 $page->assign('expertise', $res->fetchOneCell());
560 $secteurs = $ss_secteurs = Array();
562 "SELECT s.label, ss.label
563 FROM mentor_secteurs AS m
564 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
565 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
566 WHERE uid = {?}", $user_id);
567 while (list($sec, $ssec) = $res->next()) {
569 $ss_secteurs[] = $ssec;
571 $page->assign_by_ref('secteurs', $secteurs);
572 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
577 FROM mentor_pays AS m
578 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
579 WHERE uid = {?}", $user_id);
580 $page->assign('pays', $res->fetchColumn());
582 $page->addJsLink('close_on_esc.js');
585 function handler_ref_search(&$page, $action = null
, $subaction = null
)
587 require_once 'wiki.inc.php';
588 wiki_require_page('Docs.Emploi');
589 $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
591 //recuperation des noms de secteurs
592 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
594 while (list($tmp_id, $tmp_label) = $res->next()) {
595 $secteurs[$tmp_id] = $tmp_label;
597 $page->assign_by_ref('secteurs', $secteurs);
600 $res = XDB
::query("SELECT count(*) FROM mentor");
601 $page->assign('mentors_number', $res->fetchOneCell());
603 // On vient d'un formulaire
605 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
606 $secteur_sel = XDB
::escape(Env
::v('secteur'));
607 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
608 $expertise_champ = XDB
::escape(Env
::v('expertise'));
610 if ($pays_sel != "''") {
611 $where[] = "mp.pid = $pays_sel";
613 if ($secteur_sel != "''") {
614 $where[] = "ms.secteur = $secteur_sel";
615 if ($ss_secteur_sel != "''") {
616 $where[] = "ms.ss_secteur = $ss_secteur_sel";
619 if ($expertise_champ != "''") {
620 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
624 $where = join(' AND ', $where);
626 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
627 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
628 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
630 $set->addMod('mentor', 'Référents');
631 $set->apply('referent/search', $page, $action, $subaction);
632 if ($set->count() > 100) {
633 $page->assign('recherche_trop_large', true
);
636 $page->changeTpl('profile/referent.tpl');
639 function handler_ref_sect(&$page, $sect)
641 header('Content-Type: text/html; charset=utf-8');
642 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
643 $page->assign('onchange', 'setSSecteurs()');
644 $page->assign('id', 'ssect_field');
645 $page->assign('name', 'ss_secteur');
646 $it = XDB
::iterator("SELECT id,label AS field
647 FROM emploi_ss_secteur
648 WHERE secteur = {?}", $sect);
649 $page->assign('list', $it);
652 function handler_ref_country(&$page, $sect, $ssect = '')
654 header('Content-Type: text/html; charset=utf-8');
655 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
656 $page->assign('name', 'pays_sel');
657 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
658 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
659 FROM geoloc_pays AS g
660 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
661 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
662 WHERE ms.secteur = {?} $where
664 ORDER BY pays", $sect, $ssect);
665 $page->assign('list', $it);
668 function handler_p_usage(&$page)
670 $page->changeTpl('profile/nomusage.tpl');
672 require_once 'validations.inc.php';
673 require_once 'xorg.misc.inc.php';
676 "SELECT u.nom, u.nom_usage, u.flags, e.alias
677 FROM auth_user_md5 AS u
678 LEFT JOIN aliases AS e ON(u.user_id = e.id
679 AND FIND_IN_SET('usage', e.flags))
680 WHERE user_id={?}", S
::v('uid'));
682 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
683 $flags = new flagset($flags);
684 $page->assign('usage_old', $usage_old);
685 $page->assign('alias_old', $alias_old);
687 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
688 $nom_usage = strtoupper($nom_usage);
689 $page->assign('usage_req', $nom_usage);
691 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
692 // on vient de recevoir une requete, differente de l'ancien nom d'usage
693 if ($nom_usage == $nom) {
694 $page->assign('same', true
);
695 } else { // le nom de mariage est distinct du nom à l'X
696 // on calcule l'alias pour l'afficher
697 $reason = Env
::v('reason');
698 if ($reason == 'other') {
699 $reason = Env
::v('other_reason');
701 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
703 $page->assign('myusage', $myusage);
708 function handler_xnet(&$page)
710 $page->changeTpl('profile/groupesx.tpl');
711 $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
714 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
715 COUNT(e.eid) AS events, mail_domain AS lists
716 FROM groupex.membres AS m
717 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
718 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
719 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
720 $page->assign('assos', $req->fetchAllAssoc());
723 function handler_vcard(&$page, $x = null
)
731 if (substr($x, -4) == '.vcf') {
732 $x = substr($x, 0, strlen($x) - 4);
735 $vcard = new VCard($x);
736 $vcard->do_page($page);
739 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
740 $page->changeTpl('profile/admin_trombino.tpl');
741 $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
742 $page->assign('uid', $uid);
745 "SELECT a.alias,promo
746 FROM auth_user_md5 AS u
747 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
748 WHERE user_id = {?}", $uid);
749 list($forlife, $promo) = $q->fetchOneRow();
754 header("Content-type: image/jpeg");
755 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
760 $data = file_get_contents($_FILES['userfile']['tmp_name']);
761 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
762 $mimetype = substr($_FILES['userfile']['type'], 6);
763 unlink($_FILES['userfile']['tmp_name']);
765 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
766 $uid, $mimetype, $data, $x, $y);
770 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
774 $page->assign('forlife', $forlife);
776 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
777 $page->assign('xorg_title','Polytechnique.org - Administration - Binets');
778 $page->assign('title', 'Gestion des binets');
779 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
780 $table_editor->add_join_table('binets_ins','binet_id',true
);
781 $table_editor->describe('text','intitulé',true
);
782 $table_editor->apply($page, $action, $id);
784 function handler_admin_formations(&$page, $action = 'list', $id = null
) {
785 $page->assign('xorg_title','Polytechnique.org - Administration - Formations');
786 $page->assign('title', 'Gestion des formations');
787 $table_editor = new PLTableEditor('admin/formations','applis_def','id');
788 $table_editor->add_join_table('applis_ins','aid',true
);
789 $table_editor->describe('text','intitulé',true
);
790 $table_editor->describe('url','site web',false
);
791 $table_editor->apply($page, $action, $id);
793 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
794 $page->assign('xorg_title','Polytechnique.org - Administration - Sections');
795 $page->assign('title', 'Gestion des sections');
796 $table_editor = new PLTableEditor('admin/sections','sections','id');
797 $table_editor->describe('text','intitulé',true
);
798 $table_editor->apply($page, $action, $id);
800 function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null
) {
801 $page->assign('xorg_title', 'Polytechnique.org - Administration - Sous-secteurs');
802 $page->assign('title', 'Gestion des sous-secteurs');
803 $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true
);
804 $table_editor->describe('label', 'intitulé', true
);
805 $table_editor->apply($page, $action, $id);
807 function handler_admin_fonctions(&$page, $action = 'list', $id = null
) {
808 $page->assign('xorg_title', 'Polytechnique.org - Administration - Fonctions');
809 $page->assign('title', 'Gestion des fonctions');
810 $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true
);
811 $table_editor->describe('fonction_fr', 'intitulé', true
);
812 $table_editor->describe('fonction_en', 'intitulé (ang)', true
);
813 $table_editor->describe('flags', 'titre', true
);
814 $table_editor->apply($page, $action, $id);
816 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
817 $page->assign('xorg_title', 'Polytechnique.org - Administration - Secteurs');
818 $page->assign('title', 'Gestion des secteurs');
819 $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true
);
820 $table_editor->describe('label', 'intitulé', true
);
821 $table_editor->apply($page, $action, $id);
823 function handler_admin_networking(&$page, $action = 'list', $id = null
) {
824 $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
825 $page->assign('title', 'Gestion des types de networking');
826 $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
827 $table_editor->describe('name', 'intitulé', true
);
828 $table_editor->describe('icon', 'nom de l\'icône', false
);
829 $table_editor->describe('filter', 'nom du filtre à appliquer', true
);
830 $table_editor->apply($page, $action, $id);
832 function handler_admin_phones_format_display(&$page, $action = 'list', $id = null
) {
833 $page->assign('xorg_title', 'Polytechnique.org - Administration - Format d\'affichage des numéros de téléphone ');
834 $page->assign('title', 'Gestion des formats d\'affichage des numéros de téléphone');
835 $table_editor = new PLTableEditor('admin/phones_format_display', 'phone_formats', 'phoneprf',true
);
836 $table_editor->describe('phoneprf', 'Préfixe International', true
);
837 $table_editor->describe('format', 'format d\'Affichage (ex: (+p) ### ## ## ##)', true
);
838 if ($action == 'update') {
839 if ((Post
::has('phoneprf')) && (Post
::v('phoneprf') == $id)) {
840 $res = XDB
::query("SELECT format
842 WHERE phoneprf = {?}",
844 $old_val = $res->fetchOneCell();
845 if (Post
::has('format')) {
846 $new_val = Post
::v('format');
850 if ($new_val != $old_val){
851 require_once("profil.func.inc.php");
852 XDB
::execute("UPDATE phone_formats
854 WHERE phoneprf = {?}",
856 $prefixe = $id . '%';
857 $res = XDB
::iterator("SELECT uid, link_type, link_id, tel_id, tel_type, search_tel, pub
859 WHERE search_tel LIKE {?}",
863 while($phonenumber = $res->next()) {
867 $req .= "('" . addslashes($phonenumber['uid']) . "', '" . addslashes($phonenumber['link_type']) . "', '" . addslashes($phonenumber['link_id'])
868 . "', '" . addslashes($phonenumber['tel_id']) . "', '" . addslashes($phonenumber['tel_type'])
869 . "', '" . addslashes($phonenumber['search_tel']) . "', '"
870 . addslashes(format_display_number($phonenumber['search_tel'], &$erreur, array('format' => $new_val, 'phoneprf' => $id)))
871 . "', '" . addslashes($phonenumber['pub']) . "')";
874 XDB
::execute("INSERT INTO telephone(uid, link_type, link_id, tel_id ,tel_type,
875 search_tel, display_tel, pub)
877 ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)");
883 XDB
::execute("INSERT INTO telephone(uid, link_type, link_id, tel_id ,tel_type,
884 search_tel, display_tel, pub)
886 ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)");
893 $table_editor->apply($page, $action, $id);
895 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
896 $page->assign('xorg_title','Polytechnique.org - Administration - Distinctions');
897 $page->assign('title', 'Gestion des Distinctions');
898 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
899 $table_editor->describe('text', 'intitulé', true
);
900 $table_editor->describe('img', 'nom de l\'image', false
);
901 $table_editor->describe('flags', 'valider', true
);
902 $table_editor->apply($page, $action, $id);
903 if ($id && $action == 'edit') {
904 $page->changeTpl('profile/admin_decos.tpl');
908 if (Post
::v('act') == 'del') {
909 XDB
::execute('DELETE FROM profile_medals_grades
910 WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
912 foreach (Post
::v('grades', array()) as $gid=>$text) {
915 $res = XDB
::query('SELECT MAX(gid)
916 FROM profile_medals_grades
917 WHERE mid = {?}', $mid);
918 $gid = $res->fetchOneCell() +
1;
920 XDB
::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos)
921 VALUES ({?}, {?}, {?}, {?})',
922 $mid, $gid, $text, $_POST['pos']['0']);
925 XDB
::execute('UPDATE profile_medals_grades
926 SET pos={?}, text={?}
927 WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
931 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
932 $page->assign('grades', $res);
937 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: