X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fverif_adresses.inc.php;h=953f2c14b0a26c53cbb538d56736a8ab94555460;hb=eaf30d86cc99df2414cf4f171a9b0f11b0561e3b;hp=5c41f0b6ba27e8d329d7ecee161439853fa09cbe;hpb=28bda7c53f25a3f23781d5014e8183ace1572102;p=platal.git diff --git a/modules/profile/verif_adresses.inc.php b/modules/profile/verif_adresses.inc.php index 5c41f0b..953f2c1 100644 --- a/modules/profile/verif_adresses.inc.php +++ b/modules/profile/verif_adresses.inc.php @@ -56,7 +56,7 @@ function generate_new_telid($adr){ foreach($telid_array as $current_telid) if ($current_telid == $new_telid) $new_telid ++; - else + else return $new_telid;//s'ils sont differents, il y a un trou dans la liste des telid donc new_telid convient //si aucun convient, on retourne le plus grand des telid actuel + 1 return $new_telid; @@ -71,7 +71,7 @@ function replace_ifset_adr($varname, $i){ function replace_ifset_tel($varname, $i, $t){ $tab = Env::v($varname.$t, Array()); if (isset($tab[$i])) - $GLOBALS['adresses'][$i]['tels'][$t][$varname] = $tab[$i]; + $GLOBALS['adresses'][$i]['tels'][$t][$varname] = $tab[$i]; } function get_adr_arg($varname, $i) { @@ -102,7 +102,7 @@ function replace_address($i){ $adresses[$i]['nouvelle'] = 'ajout'; $adresses[$i]['adrid'] = $i; } - + replace_ifset_adr('secondaire', $i); set_flag_adr('courrier', $i); replace_ifset_adr('temporaire', $i); @@ -119,14 +119,14 @@ function replace_address($i){ replace_ifset_adr('country', $i); replace_ifset_adr('region', $i); replace_ifset_adr('pub', $i); - + for ($telid = 0; $telid <= $nb_tel_max; $telid++) { $tab = Env::v('telid'.$telid, Array()); if(isset($tab[$i])){ //ce telid etait donc present dans le formulaire replace_tel($i, $telid); } } - + if (!get_adr_arg('parsevalid', $i)) replace_ifset_adr('txt', $i); $tab = Env::v('numero_formulaire', Array()); if($tab[$i]) @@ -144,7 +144,7 @@ function geoloc_adresse($i) { $adresses[$i] = array_merge($adresses[$i], empty_address()); // localize new address $new = get_address_infos($adresses[$i]['txt']); - if (compare_addresses_text($adresses[$i]['txt'], $geotxt = get_address_text($new)) || get_adr_arg('parsevalid', $i)) + if (compare_addresses_text($adresses[$i]['txt'], $geotxt = get_address_text($new)) || get_adr_arg('parsevalid', $i)) $adresses[$i] = array_merge($adresses[$i], $new); else { $adresses[$i] = array_merge($adresses[$i], cut_address($adresses[$i]['txt'])); @@ -169,37 +169,35 @@ if ($opened_tab == 'adresses' && Env::has('modifier')){ // on ne valide que qd o $adresses_principales = 0; reset($adresses); foreach($adresses as $adrid => $adr) { - //validité de chaque adresse - $description = (($adr['numero_formulaire'] > 0)?"Adresse n°{$adr['numero_formulaire']}":"Nouvelle adresse"); - if (strlen(strtok($adr['adr1'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr1'])) - { - $page->trig("Le champ '$description - Ligne 1' contient un caractère interdit."); + //validité de chaque adresse + $description = (($adr['numero_formulaire'] > 0)?"Adresse n°{$adr['numero_formulaire']}":"Nouvelle adresse"); + if (strlen(strtok($adr['adr1'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr1'])) { + $page->trig("Le champ '$description - Ligne 1' contient un caractère interdit."); } - if (strlen(strtok($adr['adr2'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr2'])) - { - $page->trig("Le champ '$description - Ligne 2' contient un caractère interdit."); + if (strlen(strtok($adr['adr2'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr2'])) { + $page->trig("Le champ '$description - Ligne 2' contient un caractère interdit."); } - if (strlen(strtok($adr['adr3'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr3'])) - { - $page->trig("Le champ '$description - Ligne 3' contient un caractère interdit."); + if (strlen(strtok($adr['adr3'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr3'])) { + $page->trig("Le champ '$description - Ligne 3' contient un caractère interdit."); } - if (strlen(strtok($adr['postcode'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode'])) - { - $page->trig("Le champ '$description - Code Postal' contient un caractère interdit."); + if (strlen(strtok($adr['postcode'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode'])) { + $page->trig("Le champ '$description - Code Postal' contient un caractère interdit."); } - foreach ($adr['tels'] as $tel) { - if (strlen(strtok($tel['tel'],"<>{}@&#~:;?,!§*_`[]|%$^=\"")) < strlen($tel['tel'])) - { - $page->trig("Le champ '$description - ".$tel['tel_type']."' contient un caractère interdit."); - } + if (is_array($adr['tels'])) { + foreach ($adr['tels'] as $tel) { + if (strlen(strtok($tel['tel'],"<>{}@&#~:;?,!§*_`[]|%$^=\"")) < strlen($tel['tel'])) { + $page->trig("Le champ '$description - ".$tel['tel_type']."' contient un caractère interdit."); + } + } } - if(!$adr['secondaire']){ - if($adresses_principales == 1){ //deja une adresse principale - $page->trig("Tu ne peux avoir qu'une résidence principale."); - $adresses_principales++;//pour eviter de repeter le message plusieurs fois + if(!$adr['secondaire']) { + if($adresses_principales == 1) { //deja une adresse principale + $page->trig("Tu ne peux avoir qu'une résidence principale."); + $adresses_principales++; //pour eviter de repeter le message plusieurs fois + } else { + $adresses_principales = 1; + } } - else $adresses_principales = 1; - } } }