2 /***************************************************************************
3 * Copyright (C) 2003-2007 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_PUBLIC
, 'user', NO_AUTH
),
36 'profile/ajax/tel' => $this->make_hook('ajax_tel', AUTH_COOKIE
, 'user', NO_AUTH
),
37 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP
),
38 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP
),
40 'referent' => $this->make_hook('referent', AUTH_COOKIE
),
41 'emploi' => $this->make_hook('ref_search', AUTH_COOKIE
),
42 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE
),
43 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE
, 'user', NO_AUTH
),
44 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE
, 'user', NO_AUTH
),
46 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE
),
48 'vcard' => $this->make_hook('vcard', AUTH_COOKIE
, 'user', NO_HTTPS
),
49 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP
, 'admin'),
50 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP
, 'admin'),
51 'admin/formations' => $this->make_hook('admin_formations', AUTH_MDP
, 'admin'),
52 'admin/groupes-x' => $this->make_hook('admin_groupesx', AUTH_MDP
, 'admin'),
53 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP
, 'admin'),
54 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP
, 'admin'),
55 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP
, 'admin'),
61 function handler_fiche(&$page)
63 return $this->handler_profile($page, Env
::v('user'));
66 function handler_photo(&$page, $x = null
, $req = null
)
72 $res = XDB
::query("SELECT id, pub FROM aliases
73 LEFT JOIN photo ON(id = uid)
74 WHERE alias = {?}", $x);
75 list($uid, $photo_pub) = $res->fetchOneRow();
77 if ($req && S
::logged()) {
78 include 'validations.inc.php';
79 $myphoto = PhotoReq
::get_request($uid);
80 Header('Content-type: image/'.$myphoto->mimetype
);
84 "SELECT attachmime, attach
86 WHERE uid={?}", $uid);
88 if ((list($type, $data) = $res->fetchOneRow())
89 && ($photo_pub == 'public' || S
::logged())) {
90 Header("Content-type: image/$type");
93 Header('Content-type: image/png');
94 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
100 function handler_photo_change(&$page)
102 $page->changeTpl('profile/trombino.tpl');
104 require_once('validations.inc.php');
106 $trombi_x = '/home/web/trombino/photos'.S
::v('promo')
107 .'/'.S
::v('forlife').'.jpg';
109 if (Env
::has('upload')) {
110 $upload = new PlUpload(S
::v('forlife'), 'photo');
111 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
112 $page->trig('Une erreur est survenue lors du téléchargement du fichier');
114 $myphoto = new PhotoReq(S
::v('uid'), $upload);
115 if ($myphoto->isValid()) {
119 } elseif (Env
::has('trombi')) {
120 $upload = new PlUpload(S
::v('forlife'), 'photo');
121 if ($upload->copyFrom($trombi_x)) {
122 $myphoto = new PhotoReq(S
::v('uid'), $upload);
123 if ($myphoto->isValid()) {
128 } elseif (Env
::v('suppr')) {
129 XDB
::execute('DELETE FROM photo WHERE uid = {?}',
131 XDB
::execute('DELETE FROM requests
132 WHERE user_id = {?} AND type="photo"',
134 } elseif (Env
::v('cancel')) {
135 $sql = XDB
::query('DELETE FROM requests
136 WHERE user_id={?} AND type="photo"',
140 $sql = XDB
::query('SELECT COUNT(*) FROM requests
141 WHERE user_id={?} AND type="photo"',
143 $page->assign('submited', $sql->fetchOneCell());
144 $page->assign('has_trombi_x', file_exists($trombi_x));
147 function handler_profile(&$page, $x = null
)
154 require_once 'user.func.inc.php';
156 $page->changeTpl('profile/profile.tpl', SIMPLE
);
159 if (!S
::logged() || Env
::v('view') == 'public') $view = 'public';
160 if (S
::logged() && Env
::v('view') == 'ax') $view = 'ax';
162 if (is_numeric($x)) {
166 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
167 WHERE matricule={?}", $x);
168 $login = $res->fetchOneCell();
170 $login = get_user_forlife($x);
174 if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) {
175 $matches = str_replace('-', '_', $matches);
176 $res = XDB
::query("SELECT user_id
178 WHERE prenom LIKE {?} AND nom LIKE {?} AND promo = {?}
179 AND perms = 'pending'",
180 $matches[1], $matches[2], $matches[3]);
181 if ($res->numRows() == 1) {
182 $uid = $res->fetchOneCell();
183 pl_redirect('marketing/public/' . $uid);
189 $new = Env
::v('modif') == 'new';
190 $user = get_user_details($login, S
::v('uid'), $view);
191 $user['freetext'] = MiniWiki
::WikiToHTML($user['freetext']);
192 $user['cv'] = MiniWiki
::WikiToHTML($user['cv'], true
);
193 $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ?
$user['nom'] : $user['nom_usage'] );
194 $page->assign('xorg_title', $title);
198 $photo = 'photo/'.$user['forlife'].($new ?
'/req' : '');
200 if (!isset($user['y']) and !isset($user['x'])) {
201 list($user['x'], $user['y']) = getimagesize("images/none.png");
203 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
204 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
205 if ($user['x'] > 240) {
206 $user['y'] = (integer)($user['y']*240/$user['x']);
209 if ($user['y'] > 300) {
210 $user['x'] = (integer)($user['x']*300/$user['y']);
213 if ($user['x'] < 160) {
214 $user['y'] = (integer)($user['y']*160/$user['x']);
218 $page->assign('logged', has_user_right('private', $view));
219 if (!has_user_right($user['photo_pub'], $view)) {
223 $page->assign_by_ref('x', $user);
224 $page->assign('photo_url', $photo);
229 INNER JOIN virtual_redirect USING(vid)
230 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
231 WHERE ( redirect={?} OR redirect={?} )
232 AND alias LIKE '%@{$globals->mail->alias_dom}'",
234 $user['forlife'].'@'.$globals->mail
->domain
,
235 $user['forlife'].'@'.$globals->mail
->domain2
);
236 $page->assign('virtualalias', $res->fetchOneCell());
238 $page->addJsLink('close_on_esc.js');
239 header('Last-Modified: ' . date('r', strtotime($user['date'])));
242 function handler_ax(&$page, $user = null
)
244 require_once 'user.func.inc.php';
245 $user = get_user_forlife($user);
249 $res = XDB
::query('SELECT matricule_ax
250 FROM auth_user_md5 AS u
251 INNER JOIN aliases AS a ON (a.type = "a_vie" AND a.id = u.user_id)
252 WHERE a.alias = {?}', $user);
253 $mat = $res->fetchOneCell();
255 $page->kill("Le matricule AX de $user est inconnu");
257 http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
260 function handler_p_edit(&$page, $opened_tab = null
)
264 // Finish registration procedure
265 if (Post
::v('register_from_ax_question')) {
266 XDB
::execute('UPDATE auth_user_quick
267 SET profile_from_ax = 1
268 WHERE user_id = {?}',
271 if (Post
::v('add_to_nl')) {
272 require_once 'newsletter.inc.php';
273 NewsLetter
::subscribe();
275 if (Post
::v('add_to_ax')) {
276 require_once dirname(__FILE__
) . '/axletter/axletter.inc.php';
277 AXLetter
::subscribe();
279 if (Post
::v('add_to_promo')) {
280 $r = XDB
::query('SELECT id FROM groupex.asso WHERE diminutif = {?}',
282 $asso_id = $r->fetchOneCell();
283 XDB
::execute('REPLACE INTO groupex.membres (uid,asso_id)
285 S
::v('uid'), $asso_id);
286 $mmlist = new MMList(S
::v('uid'), S
::v('password'));
287 $mmlist->subscribe("promo".S
::v('promo'));
289 if (Post
::v('sub_ml')) {
290 $subs = array_keys(Post
::v('sub_ml'));
291 $current_domain = null
;
292 foreach ($subs as $list) {
293 list($sub, $domain) = explode('@', $list);
294 if ($domain != $current_domain) {
295 $current_domain = $domain;
296 $client = new MMList(S
::v('uid'), S
::v('password'), $domain);
298 $client->subscribe($sub);
302 // AX Synchronization
303 require_once 'synchro_ax.inc.php';
304 if (is_ax_key_missing()) {
305 $page->assign('no_private_key', true
);
307 if (Env
::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
308 ax_synchronize(S
::v('bestalias'), S
::v('uid'));
309 $page->trig('Ton profil a été synchronisé avec celui du site polytechniciens.com');
313 // TODO: Block if birth date is missing ?
315 $page->addJsLink('ajax.js');
316 $page->addJsLink('jquery.js');
317 $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true
);
318 require_once dirname(__FILE__
) . '/profile/page.inc.php';
319 $wiz->addPage('ProfileGeneral', 'Général', 'general');
320 $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
321 $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
322 $wiz->addPage('ProfileDeco', 'Décorations - Medals', 'deco');
323 $wiz->addPage('ProfilePro', 'Informations professionnelles', 'emploi');
324 $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
325 $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
326 $wiz->apply($page, 'profile/edit', $opened_tab);
328 $page->addCssLink('profil.css');
329 $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
332 function handler_ajax_address(&$page, $adid)
334 $page->changeTpl('profile/adresses.address.tpl', NO_SKIN
);
335 $page->assign('i', $adid);
336 $page->assign('adr', array());
337 $page->assign('ajaxadr', true
);
340 function handler_ajax_tel(&$page, $adid, $telid)
342 $page->changeTpl('profile/adresses.tel.tpl', NO_SKIN
);
343 $page->assign('i', $adid);
344 $page->assign('adid', "addresses_$adid");
345 $page->assign('adpref', "addresses[$adid]");
346 $page->assign('t', $telid);
347 $page->assign('tel', array());
348 $page->assign('ajaxtel', true
);
351 function handler_p_orange(&$page)
353 $page->changeTpl('profile/orange.tpl');
355 require_once 'validations.inc.php';
356 require_once 'xorg.misc.inc.php';
359 "SELECT u.promo, u.promo_sortie
360 FROM auth_user_md5 AS u
361 WHERE user_id={?}", S
::v('uid'));
363 list($promo, $promo_sortie_old) = $res->fetchOneRow();
364 $page->assign('promo_sortie_old', $promo_sortie_old);
365 $page->assign('promo', $promo);
367 if (!Env
::has('promo_sortie')) {
371 $promo_sortie = Env
::i('promo_sortie');
373 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
374 $page->trig('L\'année de sortie doit être un nombre de quatre chiffres');
376 elseif ($promo_sortie < $promo +
3) {
377 $page->trig('Trop tôt');
379 elseif ($promo_sortie == $promo_sortie_old) {
380 $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
382 elseif ($promo_sortie == $promo +
3) {
384 "UPDATE auth_user_md5 set promo_sortie={?}
385 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
386 $page->trig('Ton statut "orange" a été supprimé.');
387 $page->assign('promo_sortie_old', $promo_sortie);
390 $page->assign('promo_sortie', $promo_sortie);
392 if (Env
::has('submit')) {
393 $myorange = new OrangeReq(S
::v('uid'),
396 $page->assign('myorange', $myorange);
401 function handler_referent(&$page, $x = null
)
403 require_once 'user.func.inc.php';
409 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
412 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
413 FROM auth_user_md5 AS u
414 INNER JOIN aliases AS a ON (u.user_id=a.id
415 AND FIND_IN_SET('bestalias', a.flags))
416 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
418 AND a1.type!='homonyme')", $x);
420 if ($res->numRows() != 1) {
424 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
426 $page->assign('prenom', $prenom);
427 $page->assign('nom', $nom);
428 $page->assign('promo', $promo);
429 $page->assign('cv', MiniWiki
::WikiToHTML($cv, true
));
430 $page->assign('bestalias', $bestalias);
431 $page->assign('adr_pro', get_user_details_pro($user_id));
433 ///// recuperations infos referent
436 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
437 $page->assign('expertise', $res->fetchOneCell());
440 $secteurs = $ss_secteurs = Array();
442 "SELECT s.label, ss.label
443 FROM mentor_secteurs AS m
444 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
445 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
446 WHERE uid = {?}", $user_id);
447 while (list($sec, $ssec) = $res->next()) {
449 $ss_secteurs[] = $ssec;
451 $page->assign_by_ref('secteurs', $secteurs);
452 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
457 FROM mentor_pays AS m
458 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
459 WHERE uid = {?}", $user_id);
460 $page->assign('pays', $res->fetchColumn());
462 $page->addJsLink('close_on_esc.js');
465 function handler_ref_search(&$page, $action = null
, $subaction = null
)
467 require_once 'wiki.inc.php';
468 wiki_require_page('Docs.Emploi');
469 $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
471 //recuperation des noms de secteurs
472 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
474 while (list($tmp_id, $tmp_label) = $res->next()) {
475 $secteurs[$tmp_id] = $tmp_label;
477 $page->assign_by_ref('secteurs', $secteurs);
480 $res = XDB
::query("SELECT count(*) FROM mentor");
481 $page->assign('mentors_number', $res->fetchOneCell());
483 // On vient d'un formulaire
485 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
486 $secteur_sel = XDB
::escape(Env
::v('secteur'));
487 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
488 $expertise_champ = XDB
::escape(Env
::v('expertise'));
490 if ($pays_sel != "''") {
491 $where[] = "mp.pid = $pays_sel";
493 if ($secteur_sel != "''") {
494 $where[] = "ms.secteur = $secteur_sel";
495 if ($ss_secteur_sel != "''") {
496 $where[] = "ms.ss_secteur = $ss_secteur_sel";
499 if ($expertise_champ != "''") {
500 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
504 $where = join(' AND ', $where);
506 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
507 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
508 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
510 $set->addMod('mentor', 'Référents');
511 $set->apply('referent/search', $page, $action, $subaction);
512 if ($set->count() > 100) {
513 $page->assign('recherche_trop_large', true
);
516 $page->changeTpl('profile/referent.tpl');
519 function handler_ref_sect(&$page, $sect)
521 header('Content-Type: text/html; charset=utf-8');
522 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
523 $page->assign('onchange', 'setSSecteurs()');
524 $page->assign('id', 'ssect_field');
525 $page->assign('name', 'ss_secteur');
526 $it = XDB
::iterator("SELECT id,label AS field
527 FROM emploi_ss_secteur
528 WHERE secteur = {?}", $sect);
529 $page->assign('list', $it);
532 function handler_ref_country(&$page, $sect, $ssect = '')
534 header('Content-Type: text/html; charset=utf-8');
535 $page->changeTpl('include/field.select.tpl', NO_SKIN
);
536 $page->assign('name', 'pays_sel');
537 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
538 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
539 FROM geoloc_pays AS g
540 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
541 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
542 WHERE ms.secteur = {?} $where
544 ORDER BY pays", $sect, $ssect);
545 $page->assign('list', $it);
548 function handler_p_usage(&$page)
550 $page->changeTpl('profile/nomusage.tpl');
552 require_once 'validations.inc.php';
553 require_once 'xorg.misc.inc.php';
556 "SELECT u.nom, u.nom_usage, u.flags, e.alias
557 FROM auth_user_md5 AS u
558 LEFT JOIN aliases AS e ON(u.user_id = e.id
559 AND FIND_IN_SET('usage', e.flags))
560 WHERE user_id={?}", S
::v('uid'));
562 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
563 $flags = new flagset($flags);
564 $page->assign('usage_old', $usage_old);
565 $page->assign('alias_old', $alias_old);
567 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
568 $nom_usage = strtoupper($nom_usage);
569 $page->assign('usage_req', $nom_usage);
571 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
572 // on vient de recevoir une requete, differente de l'ancien nom d'usage
573 if ($nom_usage == $nom) {
574 $page->assign('same', true
);
575 } else { // le nom de mariage est distinct du nom à l'X
576 // on calcule l'alias pour l'afficher
577 $reason = Env
::v('reason');
578 if ($reason == 'other') {
579 $reason = Env
::v('other_reason');
581 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
583 $page->assign('myusage', $myusage);
588 function handler_xnet(&$page)
590 $page->changeTpl('profile/groupesx.tpl');
591 $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
594 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
595 COUNT(e.eid) AS events, mail_domain AS lists
596 FROM groupex.membres AS m
597 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
598 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
599 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
600 $page->assign('assos', $req->fetchAllAssoc());
603 function handler_vcard(&$page, $x = null
)
611 if (substr($x, -4) == '.vcf') {
612 $x = substr($x, 0, strlen($x) - 4);
615 $vcard = new VCard($x);
616 $vcard->do_page($page);
619 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
620 $page->changeTpl('profile/admin_trombino.tpl');
621 $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
622 $page->assign('uid', $uid);
625 "SELECT a.alias,promo
626 FROM auth_user_md5 AS u
627 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
628 WHERE user_id = {?}", $uid);
629 list($forlife, $promo) = $q->fetchOneRow();
634 header("Content-type: image/jpeg");
635 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
640 $data = file_get_contents($_FILES['userfile']['tmp_name']);
641 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
642 $mimetype = substr($_FILES['userfile']['type'], 6);
643 unlink($_FILES['userfile']['tmp_name']);
645 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
646 $uid, $mimetype, $data, $x, $y);
650 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
654 $page->assign('forlife', $forlife);
656 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
657 $page->assign('xorg_title','Polytechnique.org - Administration - Binets');
658 $page->assign('title', 'Gestion des binets');
659 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
660 $table_editor->add_join_table('binets_ins','binet_id',true
);
661 $table_editor->describe('text','intitulé',true
);
662 $table_editor->apply($page, $action, $id);
664 function handler_admin_formations(&$page, $action = 'list', $id = null
) {
665 $page->assign('xorg_title','Polytechnique.org - Administration - Formations');
666 $page->assign('title', 'Gestion des formations');
667 $table_editor = new PLTableEditor('admin/formations','applis_def','id');
668 $table_editor->add_join_table('applis_ins','aid',true
);
669 $table_editor->describe('text','intitulé',true
);
670 $table_editor->describe('url','site web',false
);
671 $table_editor->apply($page, $action, $id);
673 function handler_admin_groupesx(&$page, $action = 'list', $id = null
) {
674 $page->assign('xorg_title','Polytechnique.org - Administration - Groupes X');
675 $page->assign('title', 'Gestion des Groupes X');
676 $table_editor = new PLTableEditor('admin/groupes-x','groupesx_def','id');
677 $table_editor->add_join_table('groupesx_ins','gid',true
);
678 $table_editor->describe('text','intitulé',true
);
679 $table_editor->describe('url','site web',false
);
680 $table_editor->apply($page, $action, $id);
682 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
683 $page->assign('xorg_title','Polytechnique.org - Administration - Sections');
684 $page->assign('title', 'Gestion des Sections');
685 $table_editor = new PLTableEditor('admin/sections','sections','id');
686 $table_editor->describe('text','intitulé',true
);
687 $table_editor->apply($page, $action, $id);
689 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
690 $page->assign('xorg_title','Polytechnique.org - Administration - Secteurs');
691 $page->assign('title', 'Gestion des Secteurs');
692 $table_editor = new PLTableEditor('admin/secteurs','emploi_secteur','id');
693 $table_editor->describe('label','intitulé',true
);
694 $table_editor->apply($page, $action, $id);
696 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
697 $page->assign('xorg_title','Polytechnique.org - Administration - Distinctions');
698 $page->assign('title', 'Gestion des Distinctions');
699 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
700 $table_editor->describe('text', 'intitulé', true
);
701 $table_editor->describe('img', 'nom de l\'image', false
);
702 $table_editor->describe('flags', 'valider', true
);
703 $table_editor->apply($page, $action, $id);
704 if ($id && $action == 'edit') {
705 $page->changeTpl('profile/admin_decos.tpl');
709 if (Post
::v('act') == 'del') {
710 XDB
::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
711 } elseif (Post
::v('act') == 'new') {
712 XDB
::execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})',
713 $mid, max(array_keys(Post
::v('grades', array(0))))+
1);
715 foreach (Post
::v('grades', array()) as $gid=>$text) {
716 XDB
::execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid);
719 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
720 $page->assign('grades', $res);
725 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: