2 /***************************************************************************
3 * Copyright (C) 2003-2009 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/ssecteur' => $this->make_hook('ajax_ssecteur', AUTH_COOKIE
, 'user', NO_AUTH
),
43 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE
, 'user', NO_AUTH
),
44 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE
, 'user', NO_AUTH
),
45 'profile/ajax/buildnames' => $this->make_hook('ajax_buildnames', AUTH_COOKIE
, 'user', NO_AUTH
),
46 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE
),
47 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE
),
48 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC
),
49 'profile/name_info' => $this->make_hook('name_info', AUTH_PUBLIC
),
50 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP
),
52 'referent' => $this->make_hook('referent', AUTH_COOKIE
),
53 'emploi' => $this->make_hook('ref_search', AUTH_COOKIE
),
54 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE
),
55 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE
, 'user', NO_AUTH
),
56 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE
, 'user', NO_AUTH
),
58 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE
),
60 'vcard' => $this->make_hook('vcard', AUTH_COOKIE
, 'user', NO_HTTPS
),
61 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP
, 'admin'),
62 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP
, 'admin'),
63 'admin/education' => $this->make_hook('admin_education', AUTH_MDP
, 'admin'),
64 'admin/education_field' => $this->make_hook('admin_education_field', AUTH_MDP
, 'admin'),
65 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_MDP
, 'admin'),
66 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP
, 'admin'),
67 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP
, 'admin'),
68 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP
, 'admin'),
69 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP
, 'admin'),
70 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP
, 'admin'),
71 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP
, 'admin'),
72 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP
, 'admin'),
73 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_MDP
, 'admin'),
74 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_MDP
, 'admin'),
75 'admin/names' => $this->make_hook('admin_names', AUTH_MDP
, 'admin'),
81 function handler_fiche(&$page)
83 return $this->handler_profile($page, Env
::v('user'));
86 function handler_photo(&$page, $x = null
, $req = null
)
88 if (!$x ||
!($user = User
::getSilent($x))) {
92 // Retrieve the photo and its mime type.
96 if ($req && S
::logged()) {
97 include 'validations.inc.php';
98 $myphoto = PhotoReq
::get_request($user->id());
100 $photo_data = $myphoto->data
;
101 $photo_type = $myphoto->mimetype
;
105 "SELECT attachmime, attach, pub
107 WHERE uid = {?}", $user->id());
108 list($photo_type, $photo_data, $photo_pub) = $res->fetchOneRow();
109 if ($photo_pub != 'public' && !S
::logged()) {
110 $photo_type = $photo_data = null
;
114 // Display the photo, or a default one when not available.
115 if ($photo_type && $photo_data != null
) {
116 header('Content-type: image/' . $photo_type);
119 header('Content-type: image/png');
120 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
125 function handler_medal(&$page, $mid)
127 $thumb = ($mid == 'thumb');
128 $mid = $thumb ? @func_get_arg
(2) : $mid;
130 $res = XDB
::query("SELECT img
135 dirname(__FILE__
).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() :
136 dirname(__FILE__
).'/../htdocs/images/medals/' . $res->fetchOneCell();
137 $type = mime_content_type($img);
138 header("Content-Type: $type");
139 echo file_get_contents($img);
143 function handler_name_info(&$page)
145 header('Content-Type: text/html; charset=utf-8');
146 $page->changeTpl('profile/name_info.tpl', SIMPLE
);
147 $res = XDB
::iterator("SELECT name, explanations,
148 FIND_IN_SET('public', flags) AS public,
149 FIND_IN_SET('has_particle', flags) AS has_particle
150 FROM profile_name_enum
151 WHERE NOT FIND_IN_SET('not_displayed', flags)
152 ORDER BY NOT FIND_IN_SET('public', flags)");
153 $page->assign('types', $res);
156 function handler_networking(&$page, $mid)
158 $res = XDB
::query("SELECT icon
159 FROM profile_networking_enum
160 WHERE network_type = {?}",
162 $img = dirname(__FILE__
) . '/../htdocs/images/networking/' . $res->fetchOneCell();
163 $type = mime_content_type($img);
164 header("Content-Type: $type");
165 echo file_get_contents($img);
169 function handler_photo_change(&$page)
172 $page->changeTpl('profile/trombino.tpl');
174 require_once('validations.inc.php');
176 $trombi_x = '/home/web/trombino/photos' . S
::v('promo') . '/' . S
::user()->login() . '.jpg';
177 if (Env
::has('upload')) {
178 S
::assert_xsrf_token();
180 $upload = new PlUpload(S
::user()->login(), 'photo');
181 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
182 $page->trigError('Une erreur est survenue lors du téléchargement du fichier');
184 $myphoto = new PhotoReq(S
::user(), $upload);
185 if ($myphoto->isValid()) {
189 } elseif (Env
::has('trombi')) {
190 S
::assert_xsrf_token();
192 $upload = new PlUpload(S
::user()->login(), 'photo');
193 if ($upload->copyFrom($trombi_x)) {
194 $myphoto = new PhotoReq(S
::user(), $upload);
195 if ($myphoto->isValid()) {
200 } elseif (Env
::v('suppr')) {
201 S
::assert_xsrf_token();
203 XDB
::execute('DELETE FROM photo
206 XDB
::execute('DELETE FROM requests
207 WHERE user_id = {?} AND type="photo"',
209 $globals->updateNbValid();
210 } elseif (Env
::v('cancel')) {
211 S
::assert_xsrf_token();
213 $sql = XDB
::query('DELETE FROM requests
214 WHERE user_id={?} AND type="photo"',
216 $globals->updateNbValid();
219 $sql = XDB
::query('SELECT COUNT(*)
221 WHERE user_id={?} AND type="photo"',
223 $page->assign('submited', $sql->fetchOneCell());
224 $page->assign('has_trombi_x', file_exists($trombi_x));
227 function handler_profile(&$page, $x = null
)
229 // TODO/note for upcoming developers:
230 // We currently maintain both $user and $login; $user is the old way of
231 // obtaining information, and eventually everything will be loaded
232 // through $login. That is the reason why in the template $user is named
233 // $x, and $login $user (sorry for the confusion).
235 // Determines which user to display the profile of, and retrieves basic
236 // information on this user.
241 $login = (!is_numeric($x) || S
::has_perms()) ? Profile
::get($x) : null
;
244 $page->trigError($x . ' inconnu dans l\'annuaire');
249 // Now that we know this is the profile of an existing user, we can
250 // switch to the appropriate template.
251 $page->changeTpl('profile/profile.tpl', SIMPLE
);
252 require_once 'user.func.inc.php';
254 // Determines the access level at which the profile will be displayed.
255 if (!S
::logged() || Env
::v('view') == 'public') {
257 } else if (S
::logged() && Env
::v('view') == 'ax') {
263 // Determines is the user is registered, and fetches the user infos in
264 // the appropriate way.
265 $owner = $login->owner();
266 if (!$owner ||
$owner->state
!= 'pending') {
267 $new = Env
::v('modif') == 'new';
268 // XXX: Deprecated...
269 $user = get_user_details($login->hrid(), S
::i('uid'), $view);
274 pl_redirect('marketing/public/' . $owner->login());
278 // Profile view are logged.
280 S
::logger()->log('view_profile', $login->hrid());
283 // Sets the title of the html page.
284 $page->setTitle($login->fullName());
286 // Prepares the display of the user's mugshot.
287 $photo = 'photo/' . $login->hrid() . ($new ?
'/req' : '');
288 if (!isset($user['photo_pub']) ||
!has_user_right($user['photo_pub'], $view)) {
291 $page->assign('photo_url', $photo);
293 if (!isset($user['y']) and !isset($user['x'])) {
294 list($user['x'], $user['y']) = getimagesize("images/none.png");
296 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
297 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
298 if ($user['x'] > 240) {
299 $user['y'] = (integer)($user['y']*240/$user['x']);
302 if ($user['y'] > 300) {
303 $user['x'] = (integer)($user['x']*300/$user['y']);
306 if ($user['x'] < 160) {
307 $user['y'] = (integer)($user['y']*160/$user['x']);
311 // Determines and displays the virtual alias.
313 $owner = $login->owner();
315 $page->assign('virtualalias', $owner->emailAlias());
318 // Adds miscellaneous properties to the display.
319 // Adds the global user property array to the display.
320 $page->assign_by_ref('x', $user);
321 $page->assign_by_ref('user', $owner);
322 $page->assign('logged', has_user_right('private', $view));
323 $page->assign('view', $view);
325 $page->addJsLink('close_on_esc.js');
326 if (isset($user['date'])) {
327 header('Last-Modified: ' . date('r', strtotime($user['date'])));
331 function handler_ax(&$page, $user = null
)
333 $user = Profile
::get($user);
338 $page->kill("Le matricule AX de {$user->hrid()} est inconnu");
340 http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=" . $user->ax_id
);
343 function handler_p_edit(&$page, $user = null
, $opened_tab = null
, $mode = null
)
347 if (is_null($user)) {
349 if (!$user->hasProfile()) {
352 pl_redirect('profile/edit/' . $user->profile()->hrid());
355 $user = Profile
::get($user);
358 } else if (!S
::user()->canEdit($user) && Platal
::notAllowed()) {
364 $page->addJsLink('ajax.js');
365 $page->addJsLink('education.js');
366 $page->addJsLink('grades.js');
367 $page->addJsLink('profile.js');
368 $page->addJsLink('jquery.autocomplete.js');
369 $wiz = new PlWizard('Profil', PlPage
::getCoreTpl('plwizard.tpl'), true
, true
, false
);
370 $wiz->addUserData('profile', $user);
371 $wiz->addUserData('owner', $user->owner());
372 $this->load('page.inc.php');
373 $wiz->addPage('ProfileGeneral', 'Général', 'general');
374 $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
375 $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
376 $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco');
377 $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
378 $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
379 $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
380 $wiz->apply($page, 'profile/edit/' . $user->hrid(), $opened_tab, $mode);
382 if (!$user->birthdate
) {
383 $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
384 . " la procédure de récupération de mot de passe si un jour tu le perdais.");
387 $page->setTitle('Mon Profil');
390 function handler_education_js(&$page)
392 header('Content-Type: text/javascript; charset=utf-8');
393 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
394 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
395 header('Cache-Control: no-cache, must-revalidate');
396 header('Pragma: no-cache');
397 $page->changeTpl('profile/education.js.tpl', NO_SKIN
);
398 require_once "education.func.inc.php";
401 function handler_grades_js(&$page)
403 header('Content-Type: text/javascript; charset=utf-8');
404 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
405 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
406 header('Cache-Control: no-cache, must-revalidate');
407 header('Pragma: no-cache');
408 $page->changeTpl('profile/grades.js.tpl', NO_SKIN
);
409 $res = XDB
::iterator("SELECT *
410 FROM profile_medals_grades
413 while ($tmp = $res->next()) {
414 $grades[$tmp['mid']][] = $tmp;
416 $page->assign('grades', $grades);
418 $res = XDB
::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
420 ORDER BY type, text");
422 while ($tmp = $res->next()) {
423 $mlist[$tmp['type']][] = $tmp;
425 $page->assign('medal_list', $mlist);
428 function handler_ajax_address(&$page, $id)
430 header('Content-Type: text/html; charset=utf-8');
431 $page->changeTpl('profile/adresses.address.tpl', NO_SKIN
);
432 $page->assign('i', $id);
433 $page->assign('address', array());
436 function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
438 header('Content-Type: text/html; charset=utf-8');
439 $page->changeTpl('profile/phone.tpl', NO_SKIN
);
440 $page->assign('prefid', $prefid);
441 $page->assign('prefname', $prefname);
442 $page->assign('telid', $telid);
443 $page->assign('tel', array());
446 function handler_ajax_edu(&$page, $eduid, $class)
448 header('Content-Type: text/html; charset=utf-8');
449 $page->changeTpl('profile/general.edu.tpl', NO_SKIN
);
450 $res = XDB
::iterator("SELECT id, field
451 FROM profile_education_field_enum
453 $page->assign('edu_fields', $res->fetchAllAssoc());
454 $page->assign('eduid', $eduid);
455 $page->assign('class', $class);
456 require_once "education.func.inc.php";
459 function handler_ajax_medal(&$page, $id)
461 header('Content-Type: text/html; charset=utf-8');
462 $page->changeTpl('profile/deco.medal.tpl', NO_SKIN
);
463 $page->assign('id', $id);
464 $page->assign('medal', array('valid' => 0, 'grade' => 0));
467 function handler_ajax_job(&$page, $id)
469 header('Content-Type: text/html; charset=utf-8');
470 $page->changeTpl('profile/jobs.job.tpl', NO_SKIN
);
471 $page->assign('i', $id);
472 $page->assign('job', array());
473 $page->assign('new', true
);
474 $res = XDB
::query("SELECT id, name AS label
475 FROM profile_job_sector_enum");
476 $page->assign('secteurs', $res->fetchAllAssoc());
477 $res = XDB
::query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
480 $page->assign('fonctions', $res->fetchAllAssoc());
481 require_once "emails.combobox.inc.php";
482 fill_email_combobox($page);
485 function handler_ajax_secteur(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1)
487 header('Content-Type: text/html; charset=utf-8');
488 $res = XDB
::iterator("SELECT id, name AS label, FIND_IN_SET('optgroup', flags) AS optgroup
489 FROM profile_job_subsector_enum
490 WHERE sectorid = {?}", $sect);
491 $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN
);
492 $page->assign('id', $id);
493 $page->assign('ssecteurs', $res);
494 $page->assign('sel', $ssect);
496 $page->assign('change', 1);
497 $page->assign('jobid', $jobid);
498 $page->assign('jobpref', $jobpref);
502 function handler_ajax_ssecteur(&$page, $id, $ssect, $sssect = -1)
504 header('Content-Type: text/html; charset=utf-8');
505 $res = XDB
::iterator("SELECT id, name AS label
506 FROM profile_job_subsubsector_enum
507 WHERE subsectorid = {?}", $ssect);
508 $page->changeTpl('profile/jobs.soussecteur.tpl', NO_SKIN
);
509 $page->assign('id', $id);
510 $page->assign('sssecteurs', $res);
511 $page->assign('sel', $sssect);
514 function handler_ajax_skill(&$page, $cat, $id)
516 header('Content-Type: text/html; charset=utf-8');
517 $page->changeTpl('profile/skill.skill.tpl', NO_SKIN
);
518 $page->assign('cat', $cat);
519 $page->assign('id', $id);
520 if ($cat == 'competences') {
521 $page->assign('levels', array('initié' => 'initié',
522 'bonne connaissance' => 'bonne connaissance',
523 'expert' => 'expert'));
525 $page->assign('levels', array(1 => 'connaissance basique',
526 2 => 'maîtrise des bases',
527 3 => 'maîtrise limitée',
528 4 => 'maîtrise générale',
529 5 => 'bonne maîtrise',
530 6 => 'maîtrise complète'));
534 function handler_ajax_searchname(&$page, $id)
536 header('Content-Type: text/html; charset=utf-8');
537 $page->changeTpl('profile/general.searchname.tpl', NO_SKIN
);
538 $res = XDB
::query("SELECT id, name, FIND_IN_SET('public', flags) AS pub
539 FROM profile_name_enum
540 WHERE NOT FIND_IN_SET('not_displayed', flags)
541 AND NOT FIND_IN_SET('always_displayed', flags)");
542 $page->assign('sn_type_list', $res->fetchAllAssoc());
543 $page->assign('i', $id);
546 function handler_ajax_buildnames(&$page, $data)
548 header('Content-Type: text/html; charset=utf-8');
549 $page->changeTpl('profile/general.buildnames.tpl', NO_SKIN
);
550 require_once 'name.func.inc.php';
551 $page->assign('names', build_javascript_names($data));
554 function handler_p_orange(&$page, $pid = null
)
556 $page->changeTpl('profile/orange.tpl');
558 require_once 'validations.inc.php';
559 $profile = Profile
::get($pid);
560 if (is_null($profile)) {
563 $page->assign('promo_sortie_old', $profile->grad_year
);
564 $page->assign('promo', $profile->entry_year
);
565 $page->assign('promo_display', $profile->promo());
566 $page->assign('sexe', $profile->isFemale());
568 if (!Env
::has('promo_sortie')) {
571 S
::assert_xsrf_token();
574 $promo_sortie = Env
::i('promo_sortie');
575 $promo = $profile->entry_year
;
576 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
577 $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres.');
578 } elseif ($promo_sortie < $promo +
3) {
579 $page->trigError('Trop tôt !');
580 } elseif ($promo_sortie == $promo_sortie_old) {
581 $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
582 } elseif ($promo_sortie == $promo +
3) {
583 XDB
::execute('UPDATE profile_education
585 WHERE uid = {?} AND FIND_IN_SET(\'primary\', flags)',
586 $promo_sortie, $profile->id());
587 $page->trigSuccess('Ton statut "orange" a été supprimé.');
588 $page->assign('promo_sortie_old', $promo_sortie);
590 $page->assign('promo_sortie', $promo_sortie);
592 if (Env
::has('submit')) {
593 $myorange = new OrangeReq(S
::user(), $promo_sortie);
595 $page->assign('myorange', $myorange);
600 function handler_referent(&$page, $user)
602 require_once 'user.func.inc.php';
603 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
605 $user = Profile
::get($user);
610 $page->assign_by_ref('user', $user);
611 $page->assign('cv', MiniWiki
::WikiToHTML($user->cv
, true
));
612 //TODO: waiting for job refactoring to be done
613 //$page->assign('adr_pro', get_user_details_pro($user->id()));
615 ///// recuperations infos referent
618 $res = XDB
::query('SELECT expertise
620 WHERE uid = {?}', $user->id());
621 $page->assign('expertise', $res->fetchOneCell());
624 $secteurs = $ss_secteurs = Array();
625 $res = XDB
::iterRow('SELECT s.name AS label, ss.name AS label
626 FROM profile_mentor_sector AS m
627 LEFT JOIN profile_job_sector_enum AS s ON(m.sectorid = s.id)
628 LEFT JOIN profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id)
629 WHERE uid = {?}', $user->id());
630 while (list($sec, $ssec) = $res->next()) {
632 $ss_secteurs[] = $ssec;
634 $page->assign_by_ref('secteurs', $secteurs);
635 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
640 FROM profile_mentor_country AS m
641 LEFT JOIN geoloc_countries AS gc ON (m.country = gc.iso_3166_1_a2)
642 WHERE uid = {?}", $user->id());
643 $page->assign('pays', $res->fetchColumn());
645 $page->addJsLink('close_on_esc.js');
648 function handler_ref_search(&$page, $action = null
, $subaction = null
)
650 $wp = new PlWikiPage('Docs.Emploi');
653 $page->setTitle('Conseil Pro');
655 //recuperation des noms de secteurs
656 $res = XDB
::iterRow("SELECT id, name AS label FROM profile_job_sector_enum");
658 while (list($tmp_id, $tmp_label) = $res->next()) {
659 $secteurs[$tmp_id] = $tmp_label;
661 $page->assign_by_ref('secteurs', $secteurs);
664 $res = XDB
::query("SELECT count(*) FROM profile_mentor");
665 $page->assign('mentors_number', $res->fetchOneCell());
667 // On vient d'un formulaire
669 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
670 $secteur_sel = XDB
::escape(Env
::v('secteur'));
671 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
672 $expertise_champ = XDB
::escape(Env
::v('expertise'));
674 if ($pays_sel != "''") {
675 $where[] = "mp.country = $pays_sel";
677 if ($secteur_sel != "''") {
678 $where[] = "ms.sectorid = $secteur_sel";
679 if ($ss_secteur_sel != "''") {
680 $where[] = "ms.subsectorid = $ss_secteur_sel";
683 if ($expertise_champ != "''") {
684 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
688 $where = join(' AND ', $where);
690 $set = new UserSet("INNER JOIN profile_mentor AS m ON (m.uid = u.user_id)
691 LEFT JOIN profile_mentor_country AS mp ON (mp.uid = m.uid)
692 LEFT JOIN profile_mentor_sector AS ms ON (ms.uid = m.uid)",
694 $set->addMod('mentor', 'Référents');
695 $set->apply('referent/search', $page, $action, $subaction);
696 if ($set->count() > 100) {
697 $page->assign('recherche_trop_large', true
);
700 $page->changeTpl('profile/referent.tpl');
703 function handler_ref_sect(&$page, $sect)
705 header('Content-Type: text/html; charset=utf-8');
706 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
707 $page->assign('onchange', 'setSSecteurs()');
708 $page->assign('id', 'ssect_field');
709 $page->assign('name', 'ss_secteur');
710 $it = XDB
::iterator("SELECT id, name AS field
711 FROM profile_job_subsector_enum
712 WHERE sectorid = {?}", $sect);
713 $page->assign('list', $it);
716 function handler_ref_country(&$page, $sect, $ssect = '')
718 header('Content-Type: text/html; charset=utf-8');
719 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
720 $page->assign('name', 'pays_sel');
721 $where = ($ssect ?
' AND ms.subsectorid = {?}' : '');
722 $it = XDB
::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.countryFR AS field
723 FROM geoloc_countries AS gc
724 INNER JOIN profile_mentor_country AS mp ON (mp.country = gc.iso_3166_1_a2)
725 INNER JOIN profile_mentor_sector AS ms ON (ms.uid = mp.uid)
726 WHERE ms.sectorid = {?} " . $where . "
727 GROUP BY iso_3166_1_a2
728 ORDER BY countryFR", $sect, $ssect);
729 $page->assign('list', $it);
732 function handler_xnet(&$page)
734 $page->changeTpl('profile/groupesx.tpl');
735 $page->setTitle('Promo, Groupes X, Binets');
738 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
739 COUNT(e.eid) AS events, mail_domain AS lists
740 FROM groupex.membres AS m
741 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
742 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
743 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
744 $page->assign('assos', $req->fetchAllAssoc());
747 function handler_vcard(&$page, $x = null
)
755 if (substr($x, -4) == '.vcf') {
756 $x = substr($x, 0, strlen($x) - 4);
759 $vcard = new VCard();
764 function handler_admin_trombino(&$page, $login = null
, $action = null
) {
765 $page->changeTpl('profile/admin_trombino.tpl');
766 $page->setTitle('Administration - Trombino');
768 if (!$login ||
!($user = User
::get($login))) {
771 $page->assign_by_ref('user', $user);
776 header("Content-type: image/jpeg");
777 readfile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg");
782 S
::assert_xsrf_token();
784 $data = file_get_contents($_FILES['userfile']['tmp_name']);
785 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
786 $mimetype = substr($_FILES['userfile']['type'], 6);
787 unlink($_FILES['userfile']['tmp_name']);
789 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
790 $user->id(), $mimetype, $data, $x, $y);
794 S
::assert_xsrf_token();
796 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $user->id());
800 function handler_admin_names(&$page, $action = 'list', $id = null
) {
801 $page->setTitle('Administration - Types de noms');
802 $page->assign('title', 'Gestion des types de noms');
803 $table_editor = new PLTableEditor('admin/names', 'profile_name_enum', 'id', true
);
804 $table_editor->describe('name', 'Nom', true
);
805 $table_editor->describe('explanations', 'Explications', true
);
806 $table_editor->describe('type', 'Type', true
);
807 $table_editor->describe('flags', 'Flags', true
);
808 $table_editor->describe('score', 'Score', true
);
809 $table_editor->apply($page, $action, $id);
811 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
812 $page->setTitle('Administration - Binets');
813 $page->assign('title', 'Gestion des binets');
814 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
815 $table_editor->add_join_table('binets_ins','binet_id',true
);
816 $table_editor->describe('text','intitulé',true
);
817 $table_editor->apply($page, $action, $id);
819 function handler_admin_education(&$page, $action = 'list', $id = null
) {
820 $page->setTitle('Administration - Formations');
821 $page->assign('title', 'Gestion des formations');
822 $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id');
823 $table_editor->add_join_table('profile_education', 'eduid', true
);
824 $table_editor->add_join_table('profile_education_degree', 'eduid', true
);
825 $table_editor->describe('name', 'intitulé', true
);
826 $table_editor->describe('url', 'site web', false
);
827 $table_editor->apply($page, $action, $id);
829 function handler_admin_education_field(&$page, $action = 'list', $id = null
) {
830 $page->setTitle('Administration - Domaines de formation');
831 $page->assign('title', 'Gestion des domaines de formation');
832 $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true
);
833 $table_editor->add_join_table('profile_education', 'fieldid', true
);
834 $table_editor->describe('field', 'domaine', true
);
835 $table_editor->apply($page, $action, $id);
837 function handler_admin_education_degree(&$page, $action = 'list', $id = null
) {
838 $page->setTitle('Administration - Niveau de formation');
839 $page->assign('title', 'Gestion des niveau de formation');
840 $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id', true
);
841 $table_editor->add_join_table('profile_education_degree', 'degreeid', true
);
842 $table_editor->add_join_table('profile_education', 'degreeid', true
);
843 $table_editor->describe('degree', 'niveau', true
);
844 $table_editor->apply($page, $action, $id);
846 function handler_admin_education_degree_set(&$page, $action = 'list', $id = null
) {
847 $page->setTitle('Administration - Correspondances formations - niveau de formation');
848 $page->assign('title', 'Gestion des correspondances formations - niveau de formation');
849 $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true
);
850 $table_editor->describe('eduid', 'formation', true
);
851 $table_editor->describe('degreeid', 'niveau', true
);
852 $table_editor->apply($page, $action, $id);
854 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
855 $page->setTitle('Administration - Sections');
856 $page->assign('title', 'Gestion des sections');
857 $table_editor = new PLTableEditor('admin/sections','sections','id');
858 $table_editor->describe('text','intitulé',true
);
859 $table_editor->apply($page, $action, $id);
861 function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null
) {
862 $page->setTitle('Administration - Sous-secteurs');
863 $page->assign('title', 'Gestion des sous-secteurs');
864 $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true
);
865 $table_editor->describe('label', 'intitulé', true
);
866 $table_editor->apply($page, $action, $id);
868 function handler_admin_fonctions(&$page, $action = 'list', $id = null
) {
869 $page->setTitle('Administration - Fonctions');
870 $page->assign('title', 'Gestion des fonctions');
871 $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true
);
872 $table_editor->describe('fonction_fr', 'intitulé', true
);
873 $table_editor->describe('fonction_en', 'intitulé (ang)', true
);
874 $table_editor->describe('flags', 'titre', true
);
875 $table_editor->apply($page, $action, $id);
877 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
878 $page->setTitle('Administration - Secteurs');
879 $page->assign('title', 'Gestion des secteurs');
880 $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true
);
881 $table_editor->describe('label', 'intitulé', true
);
882 $table_editor->apply($page, $action, $id);
884 function handler_admin_networking(&$page, $action = 'list', $id = null
) {
885 $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
886 $page->assign('title', 'Gestion des types de networking');
887 $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
888 $table_editor->describe('name', 'intitulé', true
);
889 $table_editor->describe('icon', 'nom de l\'icône', false
);
890 $table_editor->describe('filter', 'filtre', true
);
891 $table_editor->describe('link', 'lien web', true
);
892 $table_editor->apply($page, $action, $id);
894 function handler_admin_corps_enum(&$page, $action = 'list', $id = null
) {
895 $page->setTitle('Administration - Corps');
896 $page->assign('title', 'Gestion des Corps');
897 $table_editor = new PLTableEditor('admin/corps_enum', 'profile_corps_enum', 'id');
898 $table_editor->describe('name', 'intitulé', true
);
899 $table_editor->describe('abbreviation', 'abbréviation', true
);
900 $table_editor->describe('still_exists', 'existe encore ?', true
);
901 $table_editor->apply($page, $action, $id);
903 function handler_admin_corps_rank(&$page, $action = 'list', $id = null
) {
904 $page->setTitle('Administration - Grade dans les Corps');
905 $page->assign('title', 'Gestion des grade dans les Corps');
906 $table_editor = new PLTableEditor('admin/corps_rank', 'profile_corps_rank_enum', 'id');
907 $table_editor->describe('name', 'intitulé', true
);
908 $table_editor->describe('abbreviation', 'abbréviation', true
);
909 $table_editor->apply($page, $action, $id);
911 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
912 $page->setTitle('Administration - Distinctions');
913 $page->assign('title', 'Gestion des Distinctions');
914 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
915 $table_editor->describe('text', 'intitulé', true
);
916 $table_editor->describe('img', 'nom de l\'image', false
);
917 $table_editor->describe('flags', 'valider', true
);
918 $table_editor->apply($page, $action, $id);
919 if ($id && $action == 'edit') {
920 $page->changeTpl('profile/admin_decos.tpl');
924 if (Post
::v('act') == 'del') {
925 XDB
::execute('DELETE FROM profile_medals_grades
926 WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
928 foreach (Post
::v('grades', array()) as $gid=>$text) {
931 $res = XDB
::query('SELECT MAX(gid)
932 FROM profile_medals_grades
933 WHERE mid = {?}', $mid);
934 $gid = $res->fetchOneCell() +
1;
936 XDB
::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos)
937 VALUES ({?}, {?}, {?}, {?})',
938 $mid, $gid, $text, $_POST['pos']['0']);
941 XDB
::execute('UPDATE profile_medals_grades
942 SET pos={?}, text={?}
943 WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
947 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
948 $page->assign('grades', $res);
953 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: