un petit coup de tel
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 18 Nov 2006 00:28:51 +0000 (00:28 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 18 Nov 2006 00:28:51 +0000 (00:28 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1099 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
include/geoloc.inc.php
include/profil/assign_adresses.inc.php
include/profil/get_adresses.inc.php
include/profil/update_adresses.inc.php
modules/profile.php
templates/profil/adresses.tpl

index 9472cdd..522c9f2 100644 (file)
--- 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
index ea90510..29af4be 100644 (file)
@@ -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);
 }
 // }}}
index 9a9912e..c811deb 100644 (file)
@@ -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));
index d31c651..8b14672 100644 (file)
@@ -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 = '';
index 103a2c2..775af6d 100644 (file)
@@ -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(
index fdaa2a7..71204b7 100644 (file)
@@ -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');
         }
index 71ccf28..4ea550a 100644 (file)
@@ -47,7 +47,7 @@
         <input type="hidden" name="numero_formulaire[{$adrid}]" value="{$smarty.section.i.index}" />
         {/if}
         {if $adr.nouvelle != 'new'}
-        [<a href="profile/edit/{$onglet}?adrid_del[{$adrid}]=1" style="color:inherit">La supprimer !</a>]
+        <a href="profile/edit/{$onglet}?adrid_del[{$adrid}]=1" style="color:inherit">{icon name=cross title="Supprimer cette adresse"}</a>
         {/if}
       </th>
     </tr>
     <tr class="flags">
       <td class="colg">
         <input type="hidden" name="telid{$tel.telid}[{$adrid}]" value="{$tel.telid}"/>
-        {if $tel.new_tel}
+        {if $tel.new_tel && !$tel.tel}
           <input type="hidden" name="new_tel{$tel.telid}[{$adrid}]" value="1"/>
         {/if}
         <span class="titre" onclick="this.style.display='none';var d = document.getElementById('tel_type{$adrid}_{$tel.telid}');d.style.display='inline';d.select();d.focus();">{$tel.tel_type}&nbsp;:</span>
       </td>
       <td>
         <input type="text" size="19" maxlength="28" name="tel{$tel.telid}[{$adrid}]" value="{$tel.tel}" />
+        {if $tel.tel}
+               <a href="profile/edit/{$onglet}?adrid={$adrid}&telid={$tel.telid}&deltel=1">{icon name=cross title="Supprimer ce tél."}</a>
+       {/if}
       </td>
       {include file="include/flags.radio.tpl" name="tel_pub`$tel.telid`[$adrid]" val=$tel.tel_pub display="mini"}
     </tr>