calendrier iCal des anniversaires
[platal.git] / htdocs / profil.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
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. *
10 * *
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. *
15 * *
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 *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22require_once("xorg.inc.php");
23new_skinned_page('profil.tpl',AUTH_MDP);
24$page->addCssLink('css/profil.css');
d9a33f98 25$page->assign('xorg_title','Polytechnique.org - Mon Profil');
0337d704 26
27require_once('tabs.inc.php');
28require_once('profil.func.inc.php');
29
30if (Post::has('register_from_ax_question')) {
31 $globals->xdb->query('UPDATE auth_user_quick SET profile_from_ax = 1 WHERE user_id = {?}', Session::getInt('uid'));
32 require_once('synchro_ax.inc.php');
33 copy_from_ax(Session::getInt('uid'));
34}
35
36//on met a jour $opened_tab et $new_tab qui sont le tab du POST et le tab demande
37// Tout d'abord, quel est le tab actuel ?
38// si on vient d'un POST, old_tab etait le tab courant
39if (Env::has('old_tab') && isset($tabname_array[Env::get('old_tab')])) {
40 // on verifie que la valeur postee existe bien
41 $opened_tab = Env::get('old_tab');
42}
43$new_tab = Env::has('suivant') ? get_next_tab($opened_tab) : $opened_tab;
44
45// pour tous les tabs, la date de naissance pour verifier
46// quelle est bien rentree et la date.
47$res = $globals->xdb->query(
48 "SELECT naissance, DATE_FORMAT(date,'%d.%m.%Y')
49 FROM auth_user_md5
50 WHERE user_id={?}", Session::getInt('uid'));
51list($naissance, $date_modif_profil) = $res->fetchOneRow();
52
53// lorsqu'on n'a pas la date de naissance en base de données
54if (!$naissance) {
55 // la date de naissance n'existait pas et vient d'être soumise dans la variable
56 if (Env::has('birth')) {
57 //en cas d'erreur :
58 if (!ereg('[0-3][0-9][0-1][0-9][1][9]([0-9]{2})', Env::get('birth'))) {
59 $page->assign('etat_naissance', 'query');
60 $page->trig_run('Date de naissance incorrecte ou incohérente.');
61 }
62
63 //sinon
64 $birth = sprintf("%s-%s-%s", substr(Env::get('birth'),4,4), substr(Env::get('birth'),2,2), substr(Env::get('birth'),0,2));
65 $globals->xdb->execute("UPDATE auth_user_md5 SET naissance={?} WHERE user_id={?}", $birth, Session::getInt('uid'));
66 $page->assign('etat_naissance','ok');
67 $page->run();
68 } else {
69 $page->assign('etat_naissance','query');
70 }
71 $page->run();//on affiche le formulaire pour naissance
72}
73
74//doit-on faire un update ?
75if (Env::has('modifier') || Env::has('suivant')) {
76 require_once("profil/get_{$opened_tab}.inc.php");
77 require_once("profil/verif_{$opened_tab}.inc.php");
78
79 if($page->nb_errs()) {
80 require_once("profil/assign_{$opened_tab}.inc.php");
81 $page->assign('onglet',$opened_tab);
82 $page->assign('onglet_last',get_last_tab());
83 $page->assign('onglet_tpl',"profil/$opened_tab.tpl");
84 $page->run();
85 }
86
87 $date=date("Y-m-j");//nouvelle date de mise a jour
88
89 //On sauvegarde l'uid pour l'AX
90 /* on sauvegarde les changements dans user_changes :
91 * on a juste besoin d'insérer le user_id de la personne dans la table
92 */
93 $globals->xdb->execute('REPLACE INTO user_changes SET user_id={?}', Session::getInt('uid'));
94
95 if (!Session::has('suid')) {
96 require_once('notifs.inc.php');
97 register_watch_op(Session::getInt('uid'), WATCH_FICHE);
98 }
99
100 // mise a jour des champs relatifs au tab ouvert
101 require_once("profil/update_{$opened_tab}.inc.php");
102
103 $log =& Session::getMixed('log');
104 $log->log('profil', $opened_tab);
105 $page->assign('etat_update', 'ok');
106}
107
108require_once("profil/get_{$new_tab}.inc.php");
109require_once("profil/verif_{$new_tab}.inc.php");
110require_once("profil/assign_{$new_tab}.inc.php");
111
112$page->assign('onglet',$new_tab);
113$page->assign('onglet_last',get_last_tab());
114$page->assign('onglet_tpl',"profil/$new_tab.tpl");
115$page->run();
116
117// vim:set et sws=4 sw=4 sts=4:
118?>