From 5ee95138c566fc742f46b7eff336cbdaab11380a Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Sat, 18 Nov 2006 00:28:51 +0000 Subject: [PATCH] un petit coup de tel git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1099 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 1 + include/geoloc.inc.php | 21 +++++++++++---------- include/profil/assign_adresses.inc.php | 2 +- include/profil/get_adresses.inc.php | 16 ++++++++++++++-- include/profil/update_adresses.inc.php | 16 ++++++++++++---- modules/profile.php | 2 +- templates/profil/adresses.tpl | 7 +++++-- 7 files changed, 45 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9472cdd..522c9f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -51,6 +51,7 @@ Bug/Wish: * Profile: - #385: Add section, binets and groupes-X in vCard. -FRU - #451: vCard are RFC compliant. -FRU + - #466: Fix delete phone number. -Car - #502: Use 'alias' instead of 'aka' to specify the nickname. -FRU - #536: Can use login.promo as a valid user identifier. -FRU - #539: Medals and deco need validation from admin. -Car diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index ea90510..29af4be 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -96,11 +96,12 @@ function get_address_infos($txt) { } } } - if ($infos['sql']) + if (isset($infos['sql']) && $infos['sql']) XDB::execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']); - if ($infos['display']) + if (isset($infos['display']) && $infos['display']) XDB::execute("UPDATE geoloc_pays SET display = {?} WHERE a2 = {?}", $infos['display'], $infos['country']); - fix_cities_not_on_map(1, $infos['cityid']); + if (isset($infos['cityid'])) + fix_cities_not_on_map(1, $infos['cityid']); return $infos; } // }}} @@ -155,11 +156,11 @@ function get_new_maps($url) */ function get_address_text($adr) { $t = ""; - if ($adr['adr1']) $t.= $adr['adr1']; - if ($adr['adr2']) $t.= "\n".$adr['adr2']; - if ($adr['adr3']) $t.= "\n".$adr['adr3']; + if (isset($adr['adr1']) && $adr['adr1']) $t.= $adr['adr1']; + if (isset($adr['adr2']) && $adr['adr2']) $t.= "\n".$adr['adr2']; + if (isset($adr['adr3']) && $adr['adr3']) $t.= "\n".$adr['adr3']; $l = ""; - if ($adr['display']) { + if (isset($adr['display']) && $adr['display']) { $keys = explode(' ', $adr['display']); foreach ($keys as $key) { if (isset($adr[$key])) @@ -176,8 +177,8 @@ function get_address_text($adr) { if ($adr['region']) $l .= $adr['region']." "; if ($adr['postcode']) $l .= $adr['postcode']; } else { - if ($adr['postcode']) $l .= $adr['postcode']." "; - if ($adr['city']) $l .= $adr['city']; + if (isset($adr['postcode']) && $adr['postcode']) $l .= $adr['postcode']." "; + if (isset($adr['city']) && $adr['city']) $l .= $adr['city']; } } if ($l) $t .= "\n".trim($l); @@ -185,7 +186,7 @@ function get_address_text($adr) { $res = XDB::query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']); $adr['countrytxt'] = $res->fetchOneCell(); } - if ($adr['countrytxt']) $t .= "\n".$adr['countrytxt']; + if (isset($adr['countrytxt']) && $adr['countrytxt']) $t .= "\n".$adr['countrytxt']; return trim($t); } // }}} diff --git a/include/profil/assign_adresses.inc.php b/include/profil/assign_adresses.inc.php index 9a9912e..c811deb 100644 --- a/include/profil/assign_adresses.inc.php +++ b/include/profil/assign_adresses.inc.php @@ -47,7 +47,7 @@ unset($adrid); reset($adresses); //on génère un éventuel nouveau tel pour chaque adresse foreach($adresses as $adrid => $adr){ - if (!isset($adr['tels'])) { + if (!isset($adr['tels']) || count($adr['tels']) == 0) { $adresses[$adrid]['tels'] = array( array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Tél.', 'telid' => 0, 'new_tel' => true), array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Fax', 'telid' => 1, 'new_tel' => true)); diff --git a/include/profil/get_adresses.inc.php b/include/profil/get_adresses.inc.php index d31c651..8b14672 100644 --- a/include/profil/get_adresses.inc.php +++ b/include/profil/get_adresses.inc.php @@ -21,7 +21,7 @@ require_once('geoloc.inc.php'); -global $adresses; +global $adresses, $nb_adr_max, $nb_tel_max; // on limite à 6 adresses personnelles par utilisateur $nb_adr_max = 6; // ( = max(adrid possibles) @@ -32,10 +32,18 @@ $nb_tel_max = 4; // ( = max(telid possibles) function is_adr_empty($adrid){ $adr = &$GLOBALS['adresses'][$adrid]; + $emptytel = count($adr['tels']) == 0; + if (!$emptytel) { + $emptytel = true; + foreach ($adr['tels'] as $t) if ($t['tel']) { + $emptytel = false; + break; + } + } return ( ($adr['adr1'] == '') && ($adr['adr2'] == '') && ($adr['adr3'] == '') && ($adr['postcode'] == '') && ($adr['city'] == '') && ($adr['country'] == '00') && - (count($adr['tels']) == 0) + ($emptytel) ); } @@ -58,6 +66,10 @@ for ($i = 1; $i <= $nb_adr_max; $i++) { delete_address($i,true); } } +if (Env::i('deltel')) { + XDB::execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?} AND telid = {?}", + S::v('uid', -1), Env::i('adrid'), Env::i('telid')); +} //$sql_order = "ORDER BY (NOT FIND_IN_SET('active', statut)), FIND_IN_SET('temporaire', statut)"; $sql_order = ''; diff --git a/include/profil/update_adresses.inc.php b/include/profil/update_adresses.inc.php index 103a2c2..775af6d 100644 --- a/include/profil/update_adresses.inc.php +++ b/include/profil/update_adresses.inc.php @@ -25,14 +25,16 @@ reset($adresses); function insert_new_tel($adrid, $tel) { if ($tel['tel'] == "") return; + $r = XDB::query("SELECT MAX(telid+1) FROM tels WHERE uid = {?} AND adrid = {?}", S::v('uid',-1), $adrid); + $newid = $r->fetchOneCell(); + if (!$newid) $newid = 0; XDB::execute( "INSERT INTO tels SET tel_type = {?}, tel_pub = {?}, tel = {?}, uid = {?}, adrid = {?}, telid = {?}", $tel['tel_type'], $tel['tel_pub'], $tel['tel'], - S::v('uid', -1), $adrid, $tel['telid']); + S::v('uid', -1), $adrid, $newid); } foreach ($adresses as $adrid => $adr) { - if ($adr['nouvelle'] != 'new') { // test si on vient de creer cette adresse dans verif_adresse.inc.php @@ -51,6 +53,11 @@ foreach ($adresses as $adrid => $adr) { if ($adr["nouvelle"] == 'ajout') { //nouvelle adresse + if (is_adr_empty($adrid)) { + unset($adresses[$adrid]); + continue; + } + echo "Nouveau pas vide"; XDB::execute("INSERT INTO adresses SET adr1 = {?}, adr2 = {?}, adr3 = {?}, postcode = {?}, city = {?}, cityid = {?}, country = {?}, region = {?}, regiontxt = {?}, @@ -76,8 +83,9 @@ foreach ($adresses as $adrid => $adr) { $adr['region'], $adr['regiontxt'], $adr['pub'], $statut, S::v('uid', -1), $adrid); foreach ($adr['tels'] as $tel) { - if ($tel['new_tel']) { - insert_new_tel($adrid, $tel); + if (isset($tel['new_tel'])) { + if ($tel['new_tel']) + insert_new_tel($adrid, $tel); } else { if ($tel['tel'] != "") { XDB::execute( diff --git a/modules/profile.php b/modules/profile.php index fdaa2a7..71204b7 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -360,7 +360,7 @@ class ProfileModule extends PLModule // mise a jour des champs relatifs au tab ouvert require_once "profil/update_{$opened_tab}.inc.php"; - $log =& S::v('log'); + $log =& $_SESSION['log']; $log->log('profil', $opened_tab); $page->assign('etat_update', 'ok'); } diff --git a/templates/profil/adresses.tpl b/templates/profil/adresses.tpl index 71ccf28..4ea550a 100644 --- a/templates/profil/adresses.tpl +++ b/templates/profil/adresses.tpl @@ -47,7 +47,7 @@ {/if} {if $adr.nouvelle != 'new'} - [La supprimer !] + {icon name=cross title="Supprimer cette adresse"} {/if} @@ -101,7 +101,7 @@ - {if $tel.new_tel} + {if $tel.new_tel && !$tel.tel} {/if} {$tel.tel_type} : @@ -109,6 +109,9 @@ + {if $tel.tel} + {icon name=cross title="Supprimer ce tél."} + {/if} {include file="include/flags.radio.tpl" name="tel_pub`$tel.telid`[$adrid]" val=$tel.tel_pub display="mini"} -- 2.1.4