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