From: Pascal Corpet Date: Tue, 18 Jan 2005 12:26:25 +0000 (+0000) Subject: preparation pour la synchro avec l'ax : attention modification dans platal.conf X-Git-Tag: xorg/old~379 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e25f943ed29d45d88314033bcb4287ecdd18dd25;p=platal.git preparation pour la synchro avec l'ax : attention modification dans platal.conf git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-378 --- diff --git a/htdocs/synchro_ax.php b/htdocs/synchro_ax.php new file mode 100644 index 0000000..7e9e8f4 --- /dev/null +++ b/htdocs/synchro_ax.php @@ -0,0 +1,60 @@ +kill("cette page n'existe pas"); +} + +if (Env::has('user')) { + $login = get_user_forlife(Env::get('user')); + if ($login === false) { + $page->kill(""); + } +} + +if (Env::has('mat')) { + $res = $globals->xdb->query( + "SELECT alias + FROM aliases AS a + INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie') + WHERE matricule={?}", Env::getInt('mat')); + $login = $res->fetchOneCell(); + if (empty($login)) { + $page->kill("cette page n'existe pas"); + } +} + +$new = Env::get('modif') == 'new'; +$user = get_user_details($login, Session::getInt('uid')); + +$page->assign('x', $user); +$page->assign('ax', get_user_ax($user['user_id'])); + +$page->run(); + +?> diff --git a/include/manageurs.client.inc.php b/include/manageurs.client.inc.php new file mode 100644 index 0000000..3cbd977 --- /dev/null +++ b/include/manageurs.client.inc.php @@ -0,0 +1,35 @@ + array(0 => array('adr1' => 'test AX', 'ville' => 'Trou perdu'))); + + $client = new xmlrpc_client($url); + + global $globals; + if($array = $client->get_annuaire_infos($globals->webservice->pass, $id_assoce, $adresse)){ + + if( is_string($array) ){ + $erreur = xmlrpc_decode($array); + echo $erreur['erreurstring']."\n"; + return $erreur['erreur']; + } + else{ + manageurs_encrypt_init($id_assoce); + $reply = manageurs_decrypt_array($array); + manageurs_encrypt_close(); + return $reply; + } + } + else return false; +} + +?> diff --git a/include/synchro_ax.inc.php b/include/synchro_ax.inc.php new file mode 100644 index 0000000..5b710e0 --- /dev/null +++ b/include/synchro_ax.inc.php @@ -0,0 +1,144 @@ +xdb->query( + "SELECT matricule_ax + FROM auth_user_md5 AS u + WHERE u.user_id = {?}", $uid); + $matricule_ax = $res->fetchOneCell(); + + $array = get_annuaire_infos(2, $matricule_ax, 0); + + $ancien = $array['dump']['ancien']; + + $userax = Array(); + + $userax['uid'] = $uid; + $userax['nom'] = $ancien[0]; + $userax['prenom'] = $ancien[4]; + $userax['epouse'] = ($ancien[2] != $ancien[0])?$ancien[2]:""; + $userax['promo'] = $ancien[6]; + $userax['sexe'] = ($ancien[5] != 'M')?1:0; + $userax['nationalite'] = $ancien[9]; + $userax['date'] = substr($ancien[12], 0, 10); + $userax['mobile'] = $array['cell']; + if ($ancien[13] == 'D' || $ancien[13] == 'Z') + $userax['applis_join'] = "pas un corps"; + else + $userax['applis_join'] = "Corps ".$ancien[13]." - ".$ancien[14]; + $userax['adr_pro'] = array(); + if (is_array($array['dump']['pro'])) + foreach ($array['dump']['pro'] as $job) { + $jobax['entreprise'] = $job[1]; + $jobax['fonction'] = $job[6]; + $jobax['adr1'] = $job[10]; + $jobax['adr2'] = $job[11]; + $jobax['adr3'] = $job[12]; + $jobax['cp'] = $job[13]; + $jobax['ville'] = $job[14]; + $jobax['pays'] = $job[17]; + $jobax['tel'] = $job[19]; + $userax['adr_pro'][] = $jobax; + } + $userax['adr'] = array(); + if (is_array($array['dump']['adresse'])) + foreach ($array['dump']['adresse'] as $adr) { + $adrax['adr1'] = $adr[3]; + $adrax['adr2'] = $adr[4]; + $adrax['adr3'] = $adr[5]; + $adrax['cp'] = $adr[6]; + $adrax['ville'] = $adr[7]; + $adrax['pays'] = $adr[10]; + $adrax['tel'] = $adr[12]; + $adrax['fax'] = $adr[13]; + $userax['adr'][] = $adrax; + } + if ($raw) $userax['raw'] = $array; + + return $userax; +} + +function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null, $add_address=null, $del_pro=null, $add_pro=null) { + global $globals; + + if ($epouse) { + $globals->xdb->execute("UPDATE auth_user_md5 SET epouse = {?} WHERE user_id = {?}", $userax['epouse'], $userax['uid']); + } + + if ($mobile) { + $globals->xdb->execute("UPDATE auth_user_md5 SET mobile = {?} WHERE user_id = {?}", $userax['mobile'], $userax['uid']); + } + + if (is_array($del_address)) foreach($del_address as $adrid) { + $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid); + } + + if (is_array($add_address)) { + + $res = $globals->xdb->query("SELECT adrid FROM adresses WHERE uid = {?} ORDER BY adrid", $userax['uid']); + $adrids = $res->fetchOneColumn(); + $i_adrid = 0; + $new_adrid = 1; + + foreach($add_address as $adrid) { + + $adr = $userax['adr'][$adrid]; + + // find the next adrid not used + while ($adrids[$i_adrid] == $new_adrid) { $i_adrid++; $new_adrid++; } + + if ($adr['pays']) { + $res = $globals->xdb->query("SELECT a2 FROM geoloc_pays WHERE pays LIKE {?} OR country LIKE {?}", $adr['pays'], $adr['pays']); + $a2 = $res->fetchOneCell(); + } + if (!$a2) $a2 = '00'; + + $globals->xdb->execute( + "INSERT INTO adresses + SET uid = {?}, adrid = {?}, + adr1 = {?}, adr2 = {?}, adr3 = {?}, + cp = {?}, ville = {?}, + pays = {?}, + datemaj = NOW(), + visibilite = 'adr_ax,tel_ax'", + $userax['uid'], $new_adrid, + $adr['adr1'], $adr['adr2'], $adr['adr3'], + $adr['cp'], $adr['ville'], + $a2); + }} +} + +// vim:set et sw=4 sts=4 sws=4: +?> diff --git a/include/webservices/manageurs.inc.php b/include/webservices/manageurs.inc.php index 2dd15d0..7e9f010 100644 --- a/include/webservices/manageurs.inc.php +++ b/include/webservices/manageurs.inc.php @@ -25,13 +25,14 @@ $tripledes = ''; function manageurs_encrypt_init($id_assoce){ global $tripledes, $globals; + $cipher_key = $globals->webservice->cipher_key; if(!$tripledes){ - if(empty($globals->manageurs->manageurs_cipher_key)){ + if(empty($cipher_key)){ return 1; } $tripledes = mcrypt_module_open('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($tripledes), MCRYPT_RAND); - mcrypt_generic_init($tripledes, $globals->manageurs->manageurs_cipher_key.$id_assoce, $iv); + mcrypt_generic_init($tripledes, $cipher_key.$id_assoce, $iv); return 0; } } diff --git a/templates/synchro_ax.tpl b/templates/synchro_ax.tpl new file mode 100644 index 0000000..3b696ab --- /dev/null +++ b/templates/synchro_ax.tpl @@ -0,0 +1,57 @@ +{*************************************************************************** + * Copyright (C) 2003-2004 Polytechnique.org * + * http://opensource.polytechnique.org/ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + ***************************************************************************} + +

+ Synchronisation depuis l'AX +

+ + + + + + + +{foreach from=$ax item='val' key='i'} + + + + + +{/foreach} +
champAXx.org
+ {$i} + + {if ($i neq 'adr') and ($i neq 'adr_pro')} + {$val} + {else} + {foreach from=$val item='sval' key='j'} + {include file='geoloc/address.tpl' address=$sval} + {/foreach}{/if} + + {if ($i neq 'adr') and ($i neq 'adr_pro')} + {$x[$i]} + {else} + {foreach from=$x[$i] item='sval' key='j'} + {include file='geoloc/address.tpl' address=$sval} + {/foreach}{/if} +
+ + +{* vim:set et sw=2 sts=2 sws=2: *}