IE does not know about '
[platal.git] / htdocs / admin / synchro_ax.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
22
23require_once("xorg.inc.php");
24new_admin_page('admin/synchro_ax.tpl');
25
26require_once('user.func.inc.php');
27require_once('synchro_ax.inc.php');
28
29if (Env::has('user')) {
30 $login = get_user_forlife(Env::get('user'));
31 if ($login === false) {
32 $page->kill("");
33 }
34}
35
36if (Env::has('mat')) {
37 $res = $globals->xdb->query(
38 "SELECT alias
39 FROM aliases AS a
40 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
41 WHERE matricule={?}", Env::getInt('mat'));
42 $login = $res->fetchOneCell();
43}
44
45if ($login) {
46 $new = Env::get('modif') == 'new';
47 $user = get_user_details($login, Session::getInt('uid'));
48 $userax= get_user_ax($user['user_id']);
49
50 if (Env::has('importe')) {
51
52 $adr_dels = array();
53 foreach ($user['adr'] as $adr) {
54 if (Env::has('del_address'.$adr['adrid'])) {
55 $adr_dels[] = $adr['adrid'];
56 }
57 }
58
59 $adr_adds = array();
60 foreach ($userax['adr'] as $i => $adr) {
61 if (Env::has('add_address'.$i)) {
62 $adr_adds[] = $i;
63 }
64 }
65
66 $pro_dels = array();
67 foreach ($user['adr_pro'] as $pro) {
68 if (Env::has('del_pro'.$pro['entrid'])) {
69 $pro_dels[] = $pro['entrid'];
70 }
71 }
72
73 $pro_adds = array();
74 foreach ($userax['adr_pro'] as $i => $pro) {
75 if (Env::has('add_pro'.$i)) {
76 $pro_adds[] = $i;
77 }
78 }
79
80 import_from_ax($userax, Env::has('nom_usage'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds, Env::has('nationalite'));
81
82 }
83
84 $user = get_user_details($login, Session::getInt('uid'));
85
86 if ($userax) {
87 $user['matricule_ax'] = $userax['matricule_ax'];
88 unset($userax['matricule_ax']);
89 $user['nom'] = ucwords(strtolower($user['nom']));
90 $user['nom_usage'] = ucwords(strtolower($user['nom_usage']));
91 }
92
93 $page->assign('watch_champs',array('nom', 'nom_usage', 'prenom', 'nationalite', 'mobile'));
94 $page->assign('modifiables', array(0,1,0,1,1));
95
96 $page->assign('x', $user);
97 $page->assign('ax', $userax);
98}
99$page->run();
100
101// vim:set et sts=4 sws=4 sw=4:
102?>