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/edit' => $this->make_hook('p_edit', AUTH_MDP
),
34 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP
),
35 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP
),
37 'referent' => $this->make_hook('referent', AUTH_COOKIE
),
38 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE
),
39 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE
, 'user', NO_AUTH
),
40 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE
, 'user', NO_AUTH
),
42 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE
),
44 'vcard' => $this->make_hook('vcard', AUTH_COOKIE
),
45 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP
, 'admin'),
46 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP
, 'admin'),
47 'admin/formations' => $this->make_hook('admin_formations', AUTH_MDP
, 'admin'),
48 'admin/groupes-x' => $this->make_hook('admin_groupesx', AUTH_MDP
, 'admin'),
49 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP
, 'admin'),
50 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP
, 'admin'),
51 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP
, 'admin'),
57 function handler_fiche(&$page)
59 return $this->handler_profile($page, Env
::v('user'));
62 function handler_photo(&$page, $x = null
, $req = null
)
68 $res = XDB
::query("SELECT id, pub FROM aliases
69 LEFT JOIN photo ON(id = uid)
70 WHERE alias = {?}", $x);
71 list($uid, $photo_pub) = $res->fetchOneRow();
73 if ($req && S
::logged()) {
74 include 'validations.inc.php';
75 $myphoto = PhotoReq
::get_request($uid);
76 Header('Content-type: image/'.$myphoto->mimetype
);
80 "SELECT attachmime, attach
82 WHERE uid={?}", $uid);
84 if ((list($type, $data) = $res->fetchOneRow())
85 && ($photo_pub == 'public' || S
::logged())) {
86 Header("Content-type: image/$type");
89 Header('Content-type: image/png');
90 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
96 function handler_photo_change(&$page)
98 $page->changeTpl('profile/trombino.tpl');
100 require_once('validations.inc.php');
102 $trombi_x = '/home/web/trombino/photos'.S
::v('promo')
103 .'/'.S
::v('forlife').'.jpg';
105 if (Env
::has('upload')) {
106 $upload = new PlUpload(S
::v('forlife'), 'photo');
107 if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env
::v('photo'))) {
108 $page->trig('Une erreur est survenue lors du téléchargement du fichier');
110 $myphoto = new PhotoReq(S
::v('uid'), $upload);
111 if ($myphoto->isValid()) {
115 } elseif (Env
::has('trombi')) {
116 $upload = new PlUpload(S
::v('forlife'), 'photo');
117 if ($upload->copyFrom($trombi_x)) {
118 $myphoto = new PhotoReq(S
::v('uid'), $upload);
119 if ($myphoto->isValid()) {
124 } elseif (Env
::v('suppr')) {
125 XDB
::execute('DELETE FROM photo WHERE uid = {?}',
127 XDB
::execute('DELETE FROM requests
128 WHERE user_id = {?} AND type="photo"',
130 } elseif (Env
::v('cancel')) {
131 $sql = XDB
::query('DELETE FROM requests
132 WHERE user_id={?} AND type="photo"',
136 $sql = XDB
::query('SELECT COUNT(*) FROM requests
137 WHERE user_id={?} AND type="photo"',
139 $page->assign('submited', $sql->fetchOneCell());
140 $page->assign('has_trombi_x', file_exists($trombi_x));
143 function handler_profile(&$page, $x = null
)
150 require_once 'user.func.inc.php';
152 $page->changeTpl('profile/profile.tpl', SIMPLE
);
155 if (!S
::logged() || Env
::v('view') == 'public') $view = 'public';
156 if (S
::logged() && Env
::v('view') == 'ax') $view = 'ax';
158 if (is_numeric($x)) {
162 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
163 WHERE matricule={?}", $x);
164 $login = $res->fetchOneCell();
166 $login = get_user_forlife($x);
170 if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) {
171 $matches = str_replace('-', '_', $matches);
172 $res = XDB
::query("SELECT user_id
174 WHERE prenom LIKE {?} AND nom LIKE {?} AND promo = {?}
175 AND perms = 'pending'",
176 $matches[1], $matches[2], $matches[3]);
177 if ($res->numRows() == 1) {
178 $uid = $res->fetchOneCell();
179 pl_redirect('marketing/public/' . $uid);
185 $new = Env
::v('modif') == 'new';
186 $user = get_user_details($login, S
::v('uid'), $view);
187 $user['freetext'] = MiniWiki
::WikiToHTML($user['freetext']);
188 $user['cv'] = MiniWiki
::WikiToHTML($user['cv']);
189 $title = $user['prenom'] . ' ' . empty($user['nom_usage']) ?
$user['nom'] : $user['nom_usage'];
190 $page->assign('xorg_title', $title);
194 $photo = 'photo/'.$user['forlife'].($new ?
'/req' : '');
196 if (!isset($user['y']) and !isset($user['x'])) {
197 list($user['x'], $user['y']) = getimagesize("images/none.png");
199 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
200 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
201 if ($user['x'] > 240) {
202 $user['y'] = (integer)($user['y']*240/$user['x']);
205 if ($user['y'] > 300) {
206 $user['x'] = (integer)($user['x']*300/$user['y']);
209 if ($user['x'] < 160) {
210 $user['y'] = (integer)($user['y']*160/$user['x']);
214 $page->assign('logged', has_user_right('private', $view));
215 if (!has_user_right($user['photo_pub'], $view)) {
219 $page->assign_by_ref('x', $user);
220 $page->assign('photo_url', $photo);
225 INNER JOIN virtual_redirect USING(vid)
226 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
227 WHERE ( redirect={?} OR redirect={?} )
228 AND alias LIKE '%@{$globals->mail->alias_dom}'",
230 $user['forlife'].'@'.$globals->mail
->domain
,
231 $user['forlife'].'@'.$globals->mail
->domain2
);
232 $page->assign('virtualalias', $res->fetchOneCell());
234 $page->addJsLink('close_on_esc.js');
235 header('Last-Modified: ' . date('r', strtotime($user['date'])));
238 function handler_p_edit(&$page, $opened_tab = 'general')
242 $page->changeTpl('profile/edit.tpl');
244 $page->addCssLink('profil.css');
245 $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
247 require_once dirname(__FILE__
) . '/profile/tabs.inc.php';
248 require_once 'profil.func.inc.php';
249 require_once 'synchro_ax.inc.php';
251 if (Post
::v('register_from_ax_question')) {
252 XDB
::execute('UPDATE auth_user_quick
253 SET profile_from_ax = 1
254 WHERE user_id = {?}',
257 if (Post
::v('add_to_nl')) {
258 require_once 'newsletter.inc.php';
259 NewsLetter
::subscribe();
261 if (Post
::v('add_to_ax')) {
262 require_once dirname(__FILE__
) . '/axletter/axletter.inc.php';
263 AXLetter
::subscribe();
265 if (Post
::v('add_to_promo')) {
266 $r = XDB
::query('SELECT id FROM groupex.asso WHERE diminutif = {?}',
268 $asso_id = $r->fetchOneCell();
269 XDB
::execute('REPLACE INTO groupex.membres (uid,asso_id)
271 S
::v('uid'), $asso_id);
272 $mmlist = new MMList(S
::v('uid'), S
::v('password'));
273 $mmlist->subscribe("promo".S
::v('promo'));
275 if (Post
::v('sub_ml')) {
276 $subs = array_keys(Post
::v('sub_ml'));
277 $current_domain = null
;
278 foreach ($subs as $list) {
279 list($sub, $domain) = explode('@', $list);
280 if ($domain != $current_domain) {
281 $current_domain = $domain;
282 $client = new MMList(S
::v('uid'), S
::v('password'), $domain);
284 $client->subscribe($sub);
288 if (is_ax_key_missing()) {
289 $page->assign('no_private_key', true
);
292 if (Env
::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
293 ax_synchronize(S
::v('bestalias'), S
::v('uid'));
294 $page->trig('Ton profil a été synchronisé avec celui du site polytechniciens.com');
297 // pour tous les tabs, la date de naissance pour verifier
298 // quelle est bien rentree et la date.
300 "SELECT naissance, DATE_FORMAT(date, '%d.%m.%Y')
302 WHERE user_id={?}", S
::v('uid'));
303 list($naissance, $date_modif_profil) = $res->fetchOneRow();
305 // lorsqu'on n'a pas la date de naissance en base de données
307 // la date de naissance n'existait pas et vient d'être soumise dans la variable
308 if (Env
::has('birth')) {
310 if (!ereg('[0-3][0-9][0-1][0-9][1][9]([0-9]{2})', Env
::v('birth'))) {
311 $page->assign('etat_naissance', 'query');
312 $page->trig('Date de naissance incorrecte ou incohérente.');
317 $birth = sprintf("%s-%s-%s", substr(Env
::v('birth'), 4, 4),
318 substr(Env
::v('birth'), 2, 2),
319 substr(Env
::v('birth'), 0, 2));
320 XDB
::execute("UPDATE auth_user_md5
322 WHERE user_id={?}", $birth,
324 $page->assign('etat_naissance', 'ok');
328 $page->assign('etat_naissance', 'query');
329 return; // on affiche le formulaire pour naissance
332 //doit-on faire un update ?
333 if (Env
::has('modifier') || Env
::has('suivant')) {
334 require_once dirname(__FILE__
) . "/profile/get_{$opened_tab}.inc.php";
335 require_once dirname(__FILE__
) . "/profile/verif_{$opened_tab}.inc.php";
337 if($page->nb_errs()) {
338 require_once dirname(__FILE__
) . "/profile/assign_{$opened_tab}.inc.php";
339 $page->assign('onglet', $opened_tab);
340 $page->assign('onglet_tpl', "profile/$opened_tab.tpl");
344 $date=date("Y-m-j");//nouvelle date de mise a jour
346 //On sauvegarde l'uid pour l'AX
347 /* on sauvegarde les changements dans user_changes :
348 * on a juste besoin d'insérer le user_id de la personne dans la table
350 XDB
::execute('REPLACE INTO user_changes SET user_id={?}',
353 if (!S
::has('suid')) {
354 require_once 'notifs.inc.php';
355 register_watch_op(S
::v('uid'), WATCH_FICHE
);
358 // mise a jour des champs relatifs au tab ouvert
359 require_once dirname(__FILE__
) . "/profile/update_{$opened_tab}.inc.php";
361 $log =& $_SESSION['log'];
362 $log->log('profil', $opened_tab);
363 $page->assign('etat_update', 'ok');
366 if (Env
::has('suivant')) {
367 pl_redirect('profile/edit/' . get_next_tab($opened_tab));
370 require_once dirname(__FILE__
) . "/profile/get_{$opened_tab}.inc.php";
371 require_once dirname(__FILE__
) . "/profile/verif_{$opened_tab}.inc.php";
372 require_once dirname(__FILE__
) . "/profile/assign_{$opened_tab}.inc.php";
374 $page->assign('onglet', $opened_tab);
375 $page->assign('onglet_tpl', "profile/$opened_tab.tpl");
380 function handler_p_orange(&$page)
382 $page->changeTpl('profile/orange.tpl');
384 require_once 'validations.inc.php';
385 require_once 'xorg.misc.inc.php';
388 "SELECT u.promo, u.promo_sortie
389 FROM auth_user_md5 AS u
390 WHERE user_id={?}", S
::v('uid'));
392 list($promo, $promo_sortie_old) = $res->fetchOneRow();
393 $page->assign('promo_sortie_old', $promo_sortie_old);
394 $page->assign('promo', $promo);
396 if (!Env
::has('promo_sortie')) {
400 $promo_sortie = Env
::i('promo_sortie');
402 if ($promo_sortie < 1000 ||
$promo_sortie > 9999) {
403 $page->trig('L\'année de sortie doit être un nombre de quatre chiffres');
405 elseif ($promo_sortie < $promo +
3) {
406 $page->trig('Trop tôt');
408 elseif ($promo_sortie == $promo_sortie_old) {
409 $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
411 elseif ($promo_sortie == $promo +
3) {
413 "UPDATE auth_user_md5 set promo_sortie={?}
414 WHERE user_id={?}", $promo_sortie, S
::v('uid'));
415 $page->trig('Ton statut "orange" a été supprimé.');
416 $page->assign('promo_sortie_old', $promo_sortie);
419 $page->assign('promo_sortie', $promo_sortie);
421 if (Env
::has('submit')) {
422 $myorange = new OrangeReq(S
::v('uid'),
425 $page->assign('myorange', $myorange);
430 function handler_referent(&$page, $x = null
)
432 require_once 'user.func.inc.php';
438 $page->changeTpl('profile/fiche_referent.tpl', SIMPLE
);
441 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
442 FROM auth_user_md5 AS u
443 INNER JOIN aliases AS a ON (u.user_id=a.id
444 AND FIND_IN_SET('bestalias', a.flags))
445 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
447 AND a1.type!='homonyme')", $x);
449 if ($res->numRows() != 1) {
453 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
455 $page->assign('prenom', $prenom);
456 $page->assign('nom', $nom);
457 $page->assign('promo', $promo);
458 $page->assign('cv', $cv);
459 $page->assign('bestalias', $bestalias);
460 $page->assign('adr_pro', get_user_details_pro($user_id));
462 ///// recuperations infos referent
465 $res = XDB
::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
466 $page->assign('expertise', $res->fetchOneCell());
469 $secteurs = $ss_secteurs = Array();
471 "SELECT s.label, ss.label
472 FROM mentor_secteurs AS m
473 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
474 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
475 WHERE uid = {?}", $user_id);
476 while (list($sec, $ssec) = $res->next()) {
478 $ss_secteurs[] = $ssec;
480 $page->assign_by_ref('secteurs', $secteurs);
481 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
486 FROM mentor_pays AS m
487 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
488 WHERE uid = {?}", $user_id);
489 $page->assign('pays', $res->fetchColumn());
491 $page->addJsLink('close_on_esc.js');
494 function handler_ref_search(&$page, $action = null
, $subaction = null
)
496 $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
498 //recuperation des noms de secteurs
499 $res = XDB
::iterRow("SELECT id, label FROM emploi_secteur");
501 while (list($tmp_id, $tmp_label) = $res->next()) {
502 $secteurs[$tmp_id] = $tmp_label;
504 $page->assign_by_ref('secteurs', $secteurs);
507 $res = XDB
::query("SELECT count(*) FROM mentor");
508 $page->assign('mentors_number', $res->fetchOneCell());
510 // On vient d'un formulaire
512 $pays_sel = XDB
::escape(Env
::v('pays_sel'));
513 $secteur_sel = XDB
::escape(Env
::v('secteur'));
514 $ss_secteur_sel = XDB
::escape(Env
::v('ss_secteur'));
515 $expertise_champ = XDB
::escape(Env
::v('expertise'));
517 if ($pays_sel != "''") {
518 $where[] = "mp.pid = $pays_sel";
520 if ($secteur_sel != "''") {
521 $where[] = "ms.secteur = $secteur_sel";
522 if ($ss_secteur_sel != "''") {
523 $where[] = "ms.ss_secteur = $ss_secteur_sel";
526 if ($expertise_champ != "''") {
527 $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)";
531 $where = join(' AND ', $where);
533 $set = new UserSet("INNER JOIN mentor AS m ON (m.uid = u.user_id)
534 LEFT JOIN mentor_pays AS mp ON (mp.uid = m.uid)
535 LEFT JOIN mentor_secteurs AS ms ON (ms.uid = m.uid)",
537 $set->addMod('mentor', 'Référents');
538 $set->apply('referent/search', $page, $action, $subaction);
539 if ($set->count() > 100) {
540 $page->assign('recherche_trop_large', true
);
543 $page->changeTpl('profile/referent.tpl');
546 function handler_ref_sect(&$page, $sect)
548 header('Content-Type: text/html; charset=utf-8');
549 $page->changeTpl('include/select.field.tpl', NO_SKIN
);
550 $page->assign('onchange', 'setSSecteurs()');
551 $page->assign('id', 'ssect_field');
552 $page->assign('name', 'ss_secteur');
553 $it = XDB
::iterator("SELECT id,label AS field
554 FROM emploi_ss_secteur
555 WHERE secteur = {?}", $sect);
556 $page->assign('list', $it);
559 function handler_ref_country(&$page, $sect, $ssect = '')
561 header('Content-Type: text/html; charset=utf-8');
562 $page->changeTpl('include/select.field.tpl', NO_SKIN
);
563 $page->assign('name', 'pays_sel');
564 $where = ($ssect ?
' AND ms.ss_secteur = {?}' : '');
565 $it = XDB
::iterator("SELECT a2 AS id, pays AS field
566 FROM geoloc_pays AS g
567 INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
568 INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
569 WHERE ms.secteur = {?} $where
571 ORDER BY pays", $sect, $ssect);
572 $page->assign('list', $it);
575 function handler_p_usage(&$page)
577 $page->changeTpl('profile/nomusage.tpl');
579 require_once 'validations.inc.php';
580 require_once 'xorg.misc.inc.php';
583 "SELECT u.nom, u.nom_usage, u.flags, e.alias
584 FROM auth_user_md5 AS u
585 LEFT JOIN aliases AS e ON(u.user_id = e.id
586 AND FIND_IN_SET('usage', e.flags))
587 WHERE user_id={?}", S
::v('uid'));
589 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
590 $flags = new flagset($flags);
591 $page->assign('usage_old', $usage_old);
592 $page->assign('alias_old', $alias_old);
594 $nom_usage = replace_accent(trim(Env
::v('nom_usage')));
595 $nom_usage = strtoupper($nom_usage);
596 $page->assign('usage_req', $nom_usage);
598 if (Env
::has('submit') && ($nom_usage != $usage_old)) {
599 // on vient de recevoir une requete, differente de l'ancien nom d'usage
600 if ($nom_usage == $nom) {
601 $page->assign('same', true
);
602 } else { // le nom de mariage est distinct du nom à l'X
603 // on calcule l'alias pour l'afficher
604 $reason = Env
::v('reason');
605 if ($reason == 'other') {
606 $reason = Env
::v('other_reason');
608 $myusage = new UsageReq(S
::v('uid'), $nom_usage, $reason);
610 $page->assign('myusage', $myusage);
615 function handler_xnet(&$page)
617 $page->changeTpl('profile/groupesx.tpl');
618 $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
621 SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
622 COUNT(e.eid) AS events, mail_domain AS lists
623 FROM groupex.membres AS m
624 INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
625 LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
626 WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S
::i('uid'));
627 $page->assign('assos', $req->fetchAllAssoc());
630 function handler_vcard(&$page, $x = null
)
638 if (substr($x, -4) == '.vcf') {
639 $x = substr($x, 0, strlen($x) - 4);
642 $vcard = new VCard($x);
643 $vcard->do_page($page);
646 function handler_admin_trombino(&$page, $uid = null
, $action = null
) {
647 $page->changeTpl('profile/admin_trombino.tpl');
648 $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
649 $page->assign('uid', $uid);
652 "SELECT a.alias,promo
653 FROM auth_user_md5 AS u
654 INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
655 WHERE user_id = {?}", $uid);
656 list($forlife, $promo) = $q->fetchOneRow();
661 header("Content-type: image/jpeg");
662 readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
667 $data = file_get_contents($_FILES['userfile']['tmp_name']);
668 list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
669 $mimetype = substr($_FILES['userfile']['type'], 6);
670 unlink($_FILES['userfile']['tmp_name']);
672 "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
673 $uid, $mimetype, $data, $x, $y);
677 XDB
::execute('DELETE FROM photo WHERE uid = {?}', $uid);
681 $page->assign('forlife', $forlife);
683 function handler_admin_binets(&$page, $action = 'list', $id = null
) {
684 $page->assign('xorg_title','Polytechnique.org - Administration - Binets');
685 $page->assign('title', 'Gestion des binets');
686 $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
687 $table_editor->add_join_table('binets_ins','binet_id',true
);
688 $table_editor->describe('text','intitulé',true
);
689 $table_editor->apply($page, $action, $id);
691 function handler_admin_formations(&$page, $action = 'list', $id = null
) {
692 $page->assign('xorg_title','Polytechnique.org - Administration - Formations');
693 $page->assign('title', 'Gestion des formations');
694 $table_editor = new PLTableEditor('admin/formations','applis_def','id');
695 $table_editor->add_join_table('applis_ins','aid',true
);
696 $table_editor->describe('text','intitulé',true
);
697 $table_editor->describe('url','site web',false
);
698 $table_editor->apply($page, $action, $id);
700 function handler_admin_groupesx(&$page, $action = 'list', $id = null
) {
701 $page->assign('xorg_title','Polytechnique.org - Administration - Groupes X');
702 $page->assign('title', 'Gestion des Groupes X');
703 $table_editor = new PLTableEditor('admin/groupes-x','groupesx_def','id');
704 $table_editor->add_join_table('groupesx_ins','gid',true
);
705 $table_editor->describe('text','intitulé',true
);
706 $table_editor->describe('url','site web',false
);
707 $table_editor->apply($page, $action, $id);
709 function handler_admin_sections(&$page, $action = 'list', $id = null
) {
710 $page->assign('xorg_title','Polytechnique.org - Administration - Sections');
711 $page->assign('title', 'Gestion des Sections');
712 $table_editor = new PLTableEditor('admin/sections','sections','id');
713 $table_editor->describe('text','intitulé',true
);
714 $table_editor->apply($page, $action, $id);
716 function handler_admin_secteurs(&$page, $action = 'list', $id = null
) {
717 $page->assign('xorg_title','Polytechnique.org - Administration - Secteurs');
718 $page->assign('title', 'Gestion des Secteurs');
719 $table_editor = new PLTableEditor('admin/secteurs','emploi_secteur','id');
720 $table_editor->describe('label','intitulé',true
);
721 $table_editor->apply($page, $action, $id);
723 function handler_admin_medals(&$page, $action = 'list', $id = null
) {
724 $page->assign('xorg_title','Polytechnique.org - Administration - Distinctions');
725 $page->assign('title', 'Gestion des Distinctions');
726 $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
727 $table_editor->describe('text', 'intitulé', true
);
728 $table_editor->describe('img', 'nom de l\'image', false
);
729 $table_editor->describe('flags', 'valider', true
);
730 $table_editor->apply($page, $action, $id);
731 if ($id && $action == 'edit') {
732 $page->changeTpl('profile/admin_decos.tpl');
736 if (Post
::v('act') == 'del') {
737 XDB
::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post
::i('gid'));
738 } elseif (Post
::v('act') == 'new') {
739 XDB
::execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})',
740 $mid, max(array_keys(Post
::v('grades', array(0))))+
1);
742 foreach (Post
::v('grades', array()) as $gid=>$text) {
743 XDB
::execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid);
746 $res = XDB
::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
747 $page->assign('grades', $res);
752 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: