Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
8d84c630 | 3 | * Copyright (C) 2003-2009 Polytechnique.org * |
0337d704 | 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 | ||
0337d704 | 22 | require_once('user.func.inc.php'); |
23 | ||
33ae80b5 | 24 | function is_ax_key_missing() { |
25 | global $globals; | |
1a013db7 | 26 | return !isset($globals->webservice->private_key_ax) || !is_file($globals->webservice->private_key_ax); |
33ae80b5 | 27 | } |
28 | ||
dd502514 | 29 | function get_user_ax($matricule_ax, $raw=false) |
0337d704 | 30 | { |
31 | require_once('webservices/ax/client.inc'); | |
32 | ||
0337d704 | 33 | $ancien = recupere_infos_ancien($matricule_ax); |
34 | ||
35 | $userax = Array(); | |
36 | $userax['matricule_ax'] = $matricule_ax; | |
eaf30d86 | 37 | |
a953f7e7 SJ |
38 | $userax['nom'] = mb_strtoupper($ancien->Nom_patr()); |
39 | $userax['nom_usage'] = mb_strtoupper($ancien->Nom_usuel()); | |
0337d704 | 40 | if ($userax['nom_usage'] == $userax['nom']) $userax['nom_usage'] = ''; |
41 | $userax['prenom'] = $ancien->Prenom(); | |
42 | $userax['sexe'] = ($ancien->Civilite() != 'M')?1:0; | |
43 | $userax['promo'] = $ancien->Promo(); | |
dd502514 | 44 | /* $userax['nationalite'] = $ancien->Nationalite(); |
a7de4ef7 | 45 | if ($userax['nationalite'] == 'F') $userax['nationalite'] = 'Français'; */ |
0337d704 | 46 | //$userax['date'] = substr($ancien[12], 0, 10); |
dd502514 | 47 | $userax['mobile'] = trim($ancien->Mobile(0)); |
48 | /* if ($ancien->Corps() == 'D' || $ancien->Corps() == 'Z') { | |
49 | $userax['corps'] = false; | |
0337d704 | 50 | } else { |
dd502514 | 51 | $userax['corps'] = $ancien->Corps(); |
52 | $userax['corps_grade'] = $ancien->Grade(); | |
53 | } */ | |
eaf30d86 PH |
54 | $userax['adr_pro'] = array(); |
55 | ||
0337d704 | 56 | for ($i = 0; $i < $ancien->Num_Activite(); $i++) { |
57 | $jobax = array(); | |
58 | $jobax['entreprise'] = $ancien->Entreprise($i); | |
dd502514 | 59 | if (!$jobax['entreprise']) |
60 | $jobax['entreprise'] = $ancien->Adresse_act_adresse1($i); | |
61 | $jobax['poste'] = $ancien->Fonction($i); | |
0337d704 | 62 | $jobax['adr1'] = $ancien->Adresse_act_adresse1($i); |
63 | $jobax['adr2'] = $ancien->Adresse_act_adresse2($i); | |
64 | $jobax['adr3'] = $ancien->Adresse_act_adresse3($i); | |
65 | $jobax['postcode'] = $ancien->Adresse_act_code_pst($i); | |
66 | $jobax['city'] = $ancien->Adresse_act_ville($i); | |
67 | $jobax['region'] = $ancien->Adresse_act_etat_region($i); | |
a953f7e7 | 68 | $jobax['countrytxt'] = ucwords(mb_strtolower($ancien->Adresse_act_pays($i))); |
0337d704 | 69 | $jobax['tel'] = $ancien->Adresse_act_tel($i); |
70 | $jobax['fax'] = $ancien->Adresse_act_fax($i); | |
71 | $jobax['mobile'] = $ancien->Adresse_act_mobile($i); | |
dd502514 | 72 | $jobax['pub'] = 'ax'; |
73 | $jobax['tel_pub'] = 'ax'; | |
74 | $jobax['adr_pub'] = 'ax'; | |
75 | $jobax['email_pub'] = 'ax'; | |
0337d704 | 76 | $userax['adr_pro'][] = $jobax; |
77 | } | |
78 | ||
79 | $userax['adr'] = array(); | |
dd502514 | 80 | for($i=$ancien->Num_adresse() - 1; $i >= 0; $i--) { |
0337d704 | 81 | $adrax = array(); |
82 | $adrax['adr1'] = $ancien->Adresse1($i); | |
83 | $adrax['adr2'] = $ancien->Adresse2($i); | |
84 | $adrax['adr3'] = $ancien->Adresse3($i); | |
85 | $adrax['postcode'] = $ancien->Code_pst($i); | |
86 | $adrax['city'] = $ancien->Ville($i); | |
87 | $adrax['region'] = $ancien->Etat_region($i); | |
a953f7e7 | 88 | $adrax['countrytxt'] = ucwords(mb_strtolower($ancien->Pays($i))); |
dd502514 | 89 | $adrax['pub'] = 'ax'; |
90 | if ($ancien->Tel($i) || $ancien->Fax($i)) { | |
91 | $adrax['tels'] = array(); | |
92 | if ($tel = $ancien->Tel($i)) | |
a7de4ef7 | 93 | $adrax['tels'][] = array('tel' => $tel, 'tel_type' => 'Tél.', 'tel_pub' => 'ax'); |
dd502514 | 94 | if ($tel = $ancien->Fax($i)) |
95 | $adrax['tels'][] = array('tel' => $tel, 'tel_type' => 'Fax', 'tel_pub' => 'ax'); | |
0337d704 | 96 | } |
dd502514 | 97 | if ($ancien->Mobile($i)) $userax['mobile'] = $ancien->Mobile($i); |
98 | $userax['adr'][$i] = $adrax; | |
0337d704 | 99 | } |
eaf30d86 | 100 | |
dd502514 | 101 | /* $userax['formation'] = array(); |
102 | for($i=$ancien->Num_formation() - 1; $i >= 0; $i--) | |
103 | $userax['formation'][$i] = $ancien->Formation($i);*/ | |
0337d704 | 104 | |
dd502514 | 105 | return $userax; |
0337d704 | 106 | } |
107 | ||
dd502514 | 108 | function ax_synchronize($login, $uid) { |
109 | require_once('user.func.inc.php'); | |
110 | require_once 'profil.func.inc.php'; | |
111 | // get details from user, but looking only info that can be seen by ax | |
112 | $user = get_user_details($login, $uid, 'ax'); | |
113 | $userax= get_user_ax($user['matricule_ax']); | |
114 | $diff = diff_user_details($userax, $user, 'ax'); | |
115 | set_user_details($user['user_id'], $diff); | |
0337d704 | 116 | } |
a7de4ef7 | 117 | // vim:set et sw=4 sts=4 sws=4 enc=utf-8: |
0337d704 | 118 | ?> |