2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
24 function insert_new_tel($adrid, $tel) {
25 if ($tel['tel'] == "")
27 XDB
::execute( "INSERT INTO tels SET tel_type = {?}, tel_pub = {?},
28 tel = {?}, uid = {?}, adrid = {?}, telid = {?}",
29 $tel['tel_type'], $tel['tel_pub'], $tel['tel'],
30 S
::v('uid', -1), $adrid, $tel['telid']);
33 foreach ($adresses as $adrid => $adr) {
35 if ($adr['nouvelle'] != 'new') {
36 // test si on vient de creer cette adresse dans verif_adresse.inc.php
38 //construction des bits
40 if ($adr["secondaire"]) $statut .= 'res-secondaire,';
41 if ($adr["courrier"]) $statut .= 'courrier,';
42 if ($adr["active"]) $statut .= 'active,';
43 if ($adr["temporaire"]) $statut .= 'temporaire,';
44 if (! empty($statut)) $statut = substr($statut, 0, -1);
46 if ($adr["nouvelle"] == 'ajout') {
48 XDB
::execute("INSERT INTO adresses SET adr1 = {?}, adr2 = {?},
49 adr3 = {?}, postcode = {?}, city = {?}, cityid = {?},
50 country = {?}, region = {?}, regiontxt = {?},
51 pub = {?}, datemaj = NOW(), statut = {?}, uid = {?},
52 adrid = {?}", $adr['adr1'], $adr['adr2'],
53 $adr['adr3'], $adr['postcode'], $adr['city'],
54 $adr['cityid'], $adr['country'], $adr['region'],
55 $adr['regiontxt'], $adr['pub'], $statut,
56 S
::v('uid', -1), $adrid);
58 foreach ($adr['tels'] as $tel) {
59 insert_new_tel($adrid, $tel);
62 //c'est une mise à jour
63 XDB
::execute("UPDATE adresses SET adr1 = {?}, adr2 = {?},
64 adr3 = {?}, postcode = {?}, city = {?}, cityid = {?},
65 country = {?}, region = {?}, regiontxt = {?},
66 pub = {?}, datemaj = NOW(), statut = {?}
67 WHERE uid = {?} AND adrid = {?}", $adr['adr1'],
68 $adr['adr2'], $adr['adr3'], $adr['postcode'],
69 $adr['city'], $adr['cityid'], $adr['country'],
70 $adr['region'], $adr['regiontxt'], $adr['pub'],
71 $statut, S
::v('uid', -1), $adrid);
72 foreach ($adr['tels'] as $tel) {
73 if ($tel['new_tel']) {
74 insert_new_tel($adrid, $tel);
76 if ($tel['tel'] != "") {
94 "DELETE FROM tels WHERE
104 }// fin nouvelle / ancienne adresse
105 }//fin if nouvellement crée