From 79a5acea67d00315fe79f2daad4568cd4d423235 Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Wed, 7 Jun 2006 09:49:17 +0000 Subject: [PATCH] nb de tels variables par adresse, wish 400 git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@299 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/css/default.css | 8 +- htdocs/fiche.php | 10 +- include/contacts.pdf.inc.php | 10 +- include/money/paypal.inc.php | 3 +- include/profil/assign_adresses.inc.php | 82 ++++++++++++++++ include/profil/get_adresses.inc.php | 26 ++++- include/profil/update_adresses.inc.php | 66 ++++++++++--- include/profil/verif_adresses.inc.php | 141 +++++++++++---------------- include/profil/verif_emploi.inc.php | 22 ++--- include/synchro_ax.inc.php | 21 +++- include/user.func.inc.php | 24 ++++- include/webservices/manageurs.server.inc.php | 44 ++++++--- plugins/function.display_address.php | 10 +- templates/include/flags.radio.tpl | 13 ++- templates/profil/adresses.tpl | 35 ++++--- templates/vcard.tpl | 9 +- upgrade/0.9.10/02_tels.sql | 12 +++ 17 files changed, 361 insertions(+), 175 deletions(-) create mode 100644 upgrade/0.9.10/02_tels.sql diff --git a/htdocs/css/default.css b/htdocs/css/default.css index 1f1655c..fec37e1 100644 --- a/htdocs/css/default.css +++ b/htdocs/css/default.css @@ -274,22 +274,22 @@ table.flags { } table.flags input { margin: 0px 2px; padding: 0px; } -table.flags td.texte { +table.flags td.texte, tr.flags td.texte { font-size: smaller; font-weight: bold; padding: 3px; } -table.flags td.vert { +table.flags td.vert, tr.flags td.vert { background: green; padding: 3px; text-align: center; } -table.flags td.orange { +table.flags td.orange, tr.flags td.orange { background: #ff9900; padding: 3px; text-align: center; } -table.flags td.rouge { +table.flags td.rouge, tr.flags td.rouge { background: red; padding: 3px; text-align: center; diff --git a/htdocs/fiche.php b/htdocs/fiche.php index de68402..c37e37b 100644 --- a/htdocs/fiche.php +++ b/htdocs/fiche.php @@ -83,7 +83,11 @@ if (!logged() || Env::has('public')) { if ($user['web_pub'] != 'public') $user['web'] = ''; if ($user['freetext_pub'] != 'public') $user['freetext'] = ''; foreach ($user['adr'] as $i=>$adr) { - if ($adr['pub'] != 'public' && $adr['tel_pub'] != 'public') + foreach ($adr['tels'] as $j=>$tel) { + if ($tel['tel_pub'] != 'public') + unset($user['adr'][$i]['tels'][$j]); + } + if (($adr['pub'] != 'public') && (count($user['adr'][$i]['tels']) == 0)) unset($user['adr'][$i]); elseif ($adr['pub'] != 'public') { $user['adr'][$i]['adr1'] = ''; @@ -96,10 +100,6 @@ if (!logged() || Env::has('public')) { $user['adr'][$i]['country'] = '00'; $user['adr'][$i]['countrytxt'] = ''; } - elseif ($adr['tel_pub'] != 'public') { - $user['adr'][$i]['tel'] = ''; - $user['adr'][$i]['fax'] = ''; - } } foreach ($user['adr_pro'] as $i=>$adr) { if ($adr['pub'] != 'public' && $adr['tel_pub'] != 'public' && $adr['adr_pub'] != 'public' && $adr['email_pub'] != 'public') diff --git a/include/contacts.pdf.inc.php b/include/contacts.pdf.inc.php index ad74af0..3c9ad3a 100644 --- a/include/contacts.pdf.inc.php +++ b/include/contacts.pdf.inc.php @@ -182,12 +182,10 @@ class ContactsPDF extends FPDF $this->TableRow($l, $r); - if ($a['tel']) { - $this->TableRow('Téléphone', $a['tel'], 'Mono'); - } - if ($a['fax']) { - $this->TableRow('Fax', $a['fax'], 'Mono'); - } + foreach ($a['tels'] as $tel) + if ($tel['tel']) { + $this->TableRow($tel['tel_type'], $tel['tel'], 'Mono'); + } } function AddressPro($a) diff --git a/include/money/paypal.inc.php b/include/money/paypal.inc.php index bac5a75..baafbb3 100644 --- a/include/money/paypal.inc.php +++ b/include/money/paypal.inc.php @@ -77,9 +77,10 @@ class PayPal $res = $globals->xdb->query( "SELECT a.adr1 AS address1, a.adr2 AS address2, a.city, a.postcode AS zip, a.country, - IF(a.tel, a.tel, q.profile_mobile) AS night_phone_b + IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b FROM auth_user_quick AS q LEFT JOIN adresses AS a ON (q.user_id = a.uid) + LEFT JOIN tels AS t ON (t.uid = a.uid AND t.adrid = a.adrid) WHERE q.user_id = {?} AND FIND_IN_SET('active', a.statut) LIMIT 1", Session::getInt('uid')); $this->infos['client']=array_merge($info_client, $res->fetchOneAssoc()); diff --git a/include/profil/assign_adresses.inc.php b/include/profil/assign_adresses.inc.php index 72be3d2..9cab098 100644 --- a/include/profil/assign_adresses.inc.php +++ b/include/profil/assign_adresses.inc.php @@ -18,6 +18,88 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ +//on génère une éventuelle nouvelle adresse +if (!isset($adresses) || (count($adresses) < $nb_adr_max)){ + $adrid = generate_new_adrid(); + $adresses[$adrid]['adrid'] = $adrid; + $adr = &$adresses[$adrid]; + $adr['adr1'] = ''; + $adr['adr2'] = ''; + $adr['adr3'] = ''; + $adr['postcode'] = ''; + $adr['city'] = ''; + $adr['country'] = '00'; + $adr['region'] = ''; + $adr['secondaire'] = 1; + $adr['courrier'] = 0; + $adr['active'] = 0; + $adr['temporaire'] = 1; + $adr['pub'] = 'private'; + $adr['nouvelle'] = 'new'; //n'est pas issue d'un formulaire (sert dans update_adresses...) +} + +unset($adr); +unset($adrid); + +reset($adresses); +//on génère un éventuel nouveau tel pour chaque adresse +foreach($adresses as $adrid => $adr){ + if (!isset($adr['tels'])) { + $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)); + } elseif (count($adr['tels']) < $nb_tel_max) { + $adresses[$adrid]['tels'][] = + array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Autre', 'telid' => generate_new_telid($adr), 'new_tel' => true); + } +} + +unset($adr); +unset($adrid); + +//tri des adresses : + +reset($adresses); +$i = 1; +foreach($adresses as $adrid_ => $adr_){ + if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){ + $ordre_des_adrid[$i] = $adrid_; + $i++; + $est_attribuee[$adrid_] = 1; + } + else + $est_attribuee[$adrid_] = 0; +} + +reset($adresses); +foreach($adresses as $adrid_ => $adr_){ + if(($adresses[$adrid_]['secondaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // principale et non attribuee + $ordre_des_adrid[$i] = $adrid_; + $i++; + $est_attribuee[$adrid_] = 1; + } +} + +reset($adresses); +foreach($adresses as $adrid_ => $adr_){ + if(($adresses[$adrid_]['temporaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // permanente et non attribuee + $ordre_des_adrid[$i] = $adrid_; + $i++; + $est_attribuee[$adrid_] = 1; + } +} +reset($adresses); +foreach($adresses as $adrid_ => $adr_){ + if($est_attribuee[$adrid_] == 0){ // non attribuee + $ordre_des_adrid[$i] = $adrid_; + $i++; + $est_attribuee[$adrid_] = 1; + } +} + +$nb_adr = $i - 1; +$page->assign_by_ref('ordre_adrid',$ordre_des_adrid); +$page->assign('nb_adr',$nb_adr+1); $page->assign('adresses', $adresses); diff --git a/include/profil/get_adresses.inc.php b/include/profil/get_adresses.inc.php index 74bd2ab..341a563 100644 --- a/include/profil/get_adresses.inc.php +++ b/include/profil/get_adresses.inc.php @@ -23,6 +23,8 @@ require_once('geoloc.inc.php'); // on limite à 6 adresses personnelles par utilisateur $nb_adr_max = 6; // ( = max(adrid possibles) +// on limite à 4 numéros de téléphone par adresse +$nb_tel_max = 4; // ( = max(telid possibles) //les adresses sont stockées dans un tableau global indéxé par adrid; @@ -31,13 +33,14 @@ function is_adr_empty($adrid){ return ( ($adr['adr1'] == '') && ($adr['adr2'] == '') && ($adr['adr3'] == '') && ($adr['postcode'] == '') && ($adr['city'] == '') && ($adr['country'] == '00') && - ($adr['tel'] == '') && ($adr['fax'] == '') + (count($adr['tels']) == 0) ); } function delete_address($adrid, $in_request_array = false){ global $globals; $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); + $globals->xdb->execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); if($in_request_array == true){ unset($_REQUEST['adrid'][$adrid]); } @@ -67,7 +70,7 @@ $res = $globals->xdb->iterRow( FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut), FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut), adr1, adr2, adr3, postcode, city, cityid, - a.country, region, regiontxt, tel, fax, pub, tel_pub, + a.country, region, regiontxt, pub, gp.pays AS countrytxt, gp.display FROM adresses AS a INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country) WHERE uid = {?} AND NOT FIND_IN_SET('pro',statut) ".$sql_order @@ -83,13 +86,28 @@ for ($i = 0; $i < $nb_adr; $i++) { $adresses[$adrid]['secondaire'], $adresses[$adrid]['courrier'], $adresses[$adrid]['active'], $adresses[$adrid]['temporaire'], $adresses[$adrid]['adr1'], $adresses[$adrid]['adr2'], $adresses[$adrid]['adr3'], $adresses[$adrid]['postcode'], $adresses[$adrid]['city'], $adresses[$adrid]['cityid'], - $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'], $adresses[$adrid]['tel'], $adresses[$adrid]['fax'], + $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'], $adresses[$adrid]['pub'], - $adresses[$adrid]['tel_pub'],$adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next(); + $adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next(); $adresses[$adrid]['nouvelle'] = 'modif'; $adresses[$adrid]['numero_formulaire'] = -1; require_once('geoloc.inc.php'); $adresses[$adrid]['txt'] = get_address_text($adresses[$adrid]); } +$restels = $globals->xdb->iterator( + "SELECT + t.adrid, telid, tel_type, t.tel_pub, t.tel + FROM tels AS t INNER JOIN adresses AS a ON(t.uid = a.uid AND t.adrid = a.adrid) + WHERE t.uid = {?} AND NOT FIND_IN_SET('pro',statut) ORDER BY t.adrid, tel_type DESC, telid" +, Session::getInt('uid', -1) +); +while ($tel = $restels->next()) { + $adrid = $tel['adrid']; + unset($tel['adrid']); + if (!isset($adresses[$adrid]['tels'])) + $adresses[$adrid]['tels'] = array($tel); + else + $adresses[$adrid]['tels'][] = $tel; +} ?> diff --git a/include/profil/update_adresses.inc.php b/include/profil/update_adresses.inc.php index a055076..cf85507 100644 --- a/include/profil/update_adresses.inc.php +++ b/include/profil/update_adresses.inc.php @@ -19,9 +19,27 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ - reset($adresses); +function insert_new_tel($adrid, $tel) { + global $globals; + if ($tel['tel'] == "") return; + $globals->xdb->execute( + "INSERT INTO tels SET + tel_type = {?}, + tel_pub = {?}, + tel = {?}, + uid = {?}, + adrid = {?}, + telid = {?}", + $tel['tel_type'], + $tel['tel_pub'], + $tel['tel'], + Session::getInt('uid', -1), + $adrid, + $tel['telid']); +} + foreach($adresses as $adrid => $adr){ if($adr['nouvelle'] != 'new'){ // test si on vient de creer cette adresse dans verif_adresse.inc.php @@ -46,10 +64,7 @@ foreach($adresses as $adrid => $adr){ country = {?}, region = {?}, regiontxt = {?}, - tel = {?}, - fax = {?}, pub = {?}, - tel_pub = {?}, datemaj = NOW(), statut = {?}, uid = {?}, adrid = {?}", @@ -62,12 +77,12 @@ foreach($adresses as $adrid => $adr){ $adr['country'], $adr['region'], $adr['regiontxt'], - $adr['tel'], - $adr['fax'], $adr['pub'], - $adr['tel_pub'], $statut, Session::getInt('uid', -1), $adrid); + $telsvalues = ""; + foreach ($adr['tels'] as $tel) + insert_new_tel($adrid, $tel); } else{ @@ -83,10 +98,7 @@ foreach($adresses as $adrid => $adr){ country = {?}, region = {?}, regiontxt = {?}, - tel = {?}, - fax = {?}, pub = {?}, - tel_pub = {?}, datemaj = NOW(), statut = {?} WHERE uid = {?} AND adrid = {?}", @@ -99,13 +111,41 @@ foreach($adresses as $adrid => $adr){ $adr['country'], $adr['region'], $adr['regiontxt'], - $adr['tel'], - $adr['fax'], $adr['pub'], - $adr['tel_pub'], $statut, Session::getInt('uid', -1), $adrid ); + foreach ($adr['tels'] as $tel) { + if ($tel['new_tel']) + insert_new_tel($adrid, $tel); + else + if ($tel['tel'] != "") { + $globals->xdb->execute( + "UPDATE tels SET + tel_type = {?}, + tel_pub = {?}, + tel = {?} + WHERE + uid = {?} AND + adrid = {?} AND + telid = {?}", + $tel['tel_type'], + $tel['tel_pub'], + $tel['tel'], + Session::getInt('uid', -1), + $adrid, + $tel['telid']); + } else { + $globals->xdb->execute( + "DELETE FROM tels WHERE + uid = {?} AND + adrid = {?} AND + telid = {?}", + Session::getInt('uid', -1), + $adrid, + $tel['telid']); + } + } }// fin nouvelle / ancienne adresse }//fin if nouvellement crée }//fin foreach diff --git a/include/profil/verif_adresses.inc.php b/include/profil/verif_adresses.inc.php index 93ee5cb..89e79c4 100644 --- a/include/profil/verif_adresses.inc.php +++ b/include/profil/verif_adresses.inc.php @@ -43,12 +43,36 @@ function generate_new_adrid(){ return $new_adrid; } +function generate_new_telid($adr){ + $i = 0; + $telid_array = Array(); + foreach($adr['tels'] as $tel){ + $telid_array[$i] = $tel['telid']; + $i++; + } + sort($telid_array,SORT_NUMERIC); // classe les adrid dans l'ordre croissant + $new_telid = 0; + foreach($telid_array as $current_telid) + if ($current_telid == $new_telid) + $new_telid ++; + 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; +} + function replace_ifset_adr($varname, $i){ $tab = Env::getMixed($varname, Array()); if (isset($tab[$i])) $GLOBALS['adresses'][$i][$varname] = $tab[$i]; } +function replace_ifset_tel($varname, $i, $t){ + $tab = Env::getMixed($varname.$t, Array()); + if (isset($tab[$i])) + $GLOBALS['adresses'][$i]['tels'][$t][$varname] = $tab[$i]; +} + function get_adr_arg($varname, $i) { $tab = Env::getMixed($varname, Array()); return $tab[$i]; @@ -63,9 +87,16 @@ function set_flag_adr($varname,$i){ $GLOBALS['adresses'][$i][$varname] = '0'; } +function replace_tel($i, $t){ + replace_ifset_tel('telid', $i, $t); + replace_ifset_tel('tel', $i, $t); + replace_ifset_tel('tel_pub', $i, $t); + replace_ifset_tel('tel_type', $i, $t); + replace_ifset_tel('new_tel', $i, $t); +} function replace_address($i){ - global $adresses; + global $adresses, $nb_tel_max; if(!isset($adresses[$i])){ $adresses[$i]['nouvelle'] = 'ajout'; $adresses[$i]['adrid'] = $i; @@ -86,10 +117,15 @@ function replace_address($i){ replace_ifset_adr('cityid', $i); replace_ifset_adr('country', $i); replace_ifset_adr('region', $i); - replace_ifset_adr('tel', $i); - replace_ifset_adr('fax', $i); replace_ifset_adr('pub', $i); - replace_ifset_adr('tel_pub', $i); + + for ($telid = 0; $telid <= $nb_tel_max; $telid++) { + $tab = Env::getMixed('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::getMixed('numero_formulaire', Array()); if($tab[$i]) @@ -136,35 +172,33 @@ foreach($adresses as $adrid => $adr) { $description = (($adr['numero_formulaire'] > 0)?"Adresse n°{$adr['numero_formulaire']}":"Nouvelle adresse"); if (strlen(strtok($adr['adr1'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr1'])) { - $str_error = $str_error."Le champ '$description - Ligne 1' contient un caractère interdit.
"; + $page->trig("Le champ '$description - Ligne 1' contient un caractère interdit."); } if (strlen(strtok($adr['adr2'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr2'])) { - $str_error = $str_error."Le champ '$description - Ligne 2' contient un caractère interdit.
"; + $page->trig("Le champ '$description - Ligne 2' contient un caractère interdit."); } if (strlen(strtok($adr['adr3'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr3'])) { - $str_error = $str_error."Le champ '$description - Ligne 3' contient un caractère interdit.
"; + $page->trig("Le champ '$description - Ligne 3' contient un caractère interdit."); } if (strlen(strtok($adr['postcode'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode'])) { - $str_error = $str_error."Le champ '$description - Code Postal' contient un caractère interdit.
"; + $page->trig("Le champ '$description - Code Postal' contient un caractère interdit."); } if (strlen(strtok($adr['city'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode'])) { - $str_error = $str_error."Le champ '$description - Ville' contient un caractère interdit.
"; - } - if (strlen(strtok($adr['tel'],"<>{}@&#~\/:;?,!§*_`[]|%$^=\"")) < strlen($adr['tel'])) - { - $str_error = $str_error."Le champ '$description - Téléphone' contient un caractère interdit.
"; + $page->trig("Le champ '$description - Ville' contient un caractère interdit."); } - if (strlen(strtok($adr['fax'],"<>{}@&#~\/:;?,!§*_`[]|%$^=\"")) < strlen($adr['fax'])) - { - $str_error = $str_error."Le champ '$description - Fax' 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(!$adr['secondaire']){ if($adresses_principales == 1){ //deja une adresse principale - $str_error = $str_error."Tu ne peux avoir qu'une résidence 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; @@ -177,79 +211,14 @@ foreach($adresses as $adrid => $adr) { if(isset($adresses)){ // s'il y en a reset($adresses); foreach($adresses as $adrid => $adr){ + // on vire les tels vides + foreach ($adr['tels'] as $telid => $tel) { + if ($tel['tel'] == '') unset($adresses[$adrid]['tels'][$telid]); + } if(is_adr_empty($adrid)){ delete_address($adrid); } } } -//on génère une éventuelle nouvelle adresse -if (!isset($adresses) || (count($adresses) < $nb_adr_max)){ - $adrid = generate_new_adrid(); - $adresses[$adrid]['adrid'] = $adrid; - $adr = &$adresses[$adrid]; - $adr['adr1'] = ''; - $adr['adr2'] = ''; - $adr['adr3'] = ''; - $adr['postcode'] = ''; - $adr['city'] = ''; - $adr['country'] = '00'; - $adr['region'] = ''; - $adr['tel'] = ''; - $adr['fax'] = ''; - $adr['secondaire'] = 1; - $adr['courrier'] = 0; - $adr['active'] = 0; - $adr['temporaire'] = 1; - $adr['pub'] = 'private'; - $adr['tel_pub'] = 'private'; - $adr['nouvelle'] = 'new'; //n'est pas issue d'un formulaire (sert dans update_adresses...) -} - -unset($adr); -unset($adrid); - -//tri des adresses : - -reset($adresses); -$i = 1; -foreach($adresses as $adrid_ => $adr_){ - if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){ - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } - else - $est_attribuee[$adrid_] = 0; -} - -reset($adresses); -foreach($adresses as $adrid_ => $adr_){ - if(($adresses[$adrid_]['secondaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // principale et non attribuee - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } -} - -reset($adresses); -foreach($adresses as $adrid_ => $adr_){ - if(($adresses[$adrid_]['temporaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // permanente et non attribuee - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } -} -reset($adresses); -foreach($adresses as $adrid_ => $adr_){ - if($est_attribuee[$adrid_] == 0){ // non attribuee - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } -} - -$nb_adr = $i - 1; -$page->assign_by_ref('ordre_adrid',$ordre_des_adrid); -$page->assign('nb_adr',$nb_adr+1); ?> diff --git a/include/profil/verif_emploi.inc.php b/include/profil/verif_emploi.inc.php index 02f7d77..b7b4523 100644 --- a/include/profil/verif_emploi.inc.php +++ b/include/profil/verif_emploi.inc.php @@ -59,19 +59,19 @@ replace_ifset($cv,"cv"); $j = $i+1; if (strlen(strtok($entreprise[$i],"<>{}#~;!§*`[]|%^=")) < strlen($entreprise[$i])) { -$str_error = $str_error."Le champ 'Entreprise $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Entreprise $j' contient un caractère interdit."); } //validité du poste if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i])) { -$str_error = $str_error."Le champ 'Poste $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Poste $j' contient un caractère interdit."); } //validité du CV if (strlen(strtok($cv,"<>{}~§`")) < strlen($cv)) { - $str_error = $str_error."Le champ 'Curriculum vitae' contient un caractère interdit.
"; + $page->trig("Le champ 'Curriculum vitae' contient un caractère interdit."); } // correction du champ web si vide @@ -95,35 +95,35 @@ if ($emailpro[$i]) { if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i])) { - $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.
"; + $page->trig("Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit."); } if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i])) { - $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.
"; + $page->trig("Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit."); } if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i])) { - $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.
"; + $page->trig("Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit."); } if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i])) { - $str_error = $str_error."Le champ 'Code Postal professionnel $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Code Postal professionnel $j' contient un caractère interdit."); } if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i])) { - $str_error = $str_error."Le champ 'Ville professionnelle $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Ville professionnelle $j' contient un caractère interdit."); } if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i])) { - $str_error = $str_error."Le champ 'Téléphone professionnel $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Téléphone professionnel $j' contient un caractère interdit."); } if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i])) { - $str_error = $str_error."Le champ 'Fax professionnel $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Fax professionnel $j' contient un caractère interdit."); } if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i])) { - $str_error = $str_error."Le champ 'Mobile professionnel $j' contient un caractère interdit.
"; + $page->trig("Le champ 'Mobile professionnel $j' contient un caractère interdit."); } } diff --git a/include/synchro_ax.inc.php b/include/synchro_ax.inc.php index 8345172..3f78e2b 100644 --- a/include/synchro_ax.inc.php +++ b/include/synchro_ax.inc.php @@ -117,6 +117,7 @@ function import_from_ax($userax, $nom_usage=false, $mobile=false, $del_address=n } if (is_array($del_address)) foreach($del_address as $adrid) { $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid); + $globals->xdb->execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid); } if (is_array($del_pro)) foreach($del_pro as $entrid) { @@ -162,15 +163,25 @@ function import_from_ax($userax, $nom_usage=false, $mobile=false, $del_address=n adr1 = {?}, adr2 = {?}, adr3 = {?}, postcode = {?}, city = {?}, country = {?}, - tel = {?}, fax = {?}, datemaj = NOW(), - pub = 'ax', - tel_pub = 'ax'", + pub = 'ax'", $userax['uid'], $new_adrid, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['postcode'], $adr['city'], - $a2, - $adr['tel'], $adr['fax']); + $a2); + // import tels + if ($adr['tel']) + $globals->xdb->execute( + "INSERT INTO adresses + SET uid = {?}, adrid = {?}, tel = {?}, + telid = 0, tel_type = 'Tel.', tel_pub = 'ax'", + $userax["uid"], $new_adrid, $adr['tel']); + if ($adr['fax']) + $globals->xdb->execute( + "INSERT INTO adresses + SET uid = {?}, adrid = {?}, tel = {?}, + telid = 1, tel_type = 'Fax', tel_pub = 'ax'", + $userax["uid"], $new_adrid, $adr['fax']); } } diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 5de36d8..8add780 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -204,17 +204,35 @@ function &get_user_details($login, $from_uid = '') $user['adr_pro'] = get_user_details_pro($uid); - $sql = "SELECT a.adr1,a.adr2,a.adr3,a.postcode,a.city, - gp.pays AS countrytxt,a.region, a.regiontxt, a.tel,a.fax, + $sql = "SELECT a.adrid, a.adr1,a.adr2,a.adr3,a.postcode,a.city, + gp.pays AS countrytxt,a.region, a.regiontxt, FIND_IN_SET('active', a.statut) AS active, a.adrid, FIND_IN_SET('res-secondaire', a.statut) AS secondaire, - a.pub, a.tel_pub, gp.display + a.pub, gp.display FROM adresses AS a LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.country) WHERE uid= {?} AND NOT FIND_IN_SET('pro',a.statut) ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)"; $res = $globals->xdb->query($sql, $uid); $user['adr'] = $res->fetchAllAssoc(); + $adrid_index = array(); + foreach ($user['adr'] as $i => $adr) + $adrid_index[$adr['adrid']] = $i; + + $sql = "SELECT t.adrid, t.tel_pub, t.tel_type, t.tel + FROM tels AS t + INNER JOIN adresses AS a ON (a.uid = t.uid) AND (a.adrid = t.adrid) + WHERE t.uid = {?} AND NOT FIND_IN_SET('pro',a.statut) + ORDER BY t.adrid, t.tel_type DESC, t.telid"; + $restel = $globals->xdb->iterator($sql, $uid); + while ($nexttel = $restel->next()) { + $adrid = $nexttel['adrid']; + unset($nexttel['adrid']); + if (!isset($user['adr'][$adrid_index[$adrid]]['tels'])) + $user['adr'][$adrid_index[$adrid]]['tels'] = array($nexttel); + else + $user['adr'][$adrid_index[$adrid]]['tels'][] = $nexttel; + } $sql = "SELECT text FROM binets_ins diff --git a/include/webservices/manageurs.server.inc.php b/include/webservices/manageurs.server.inc.php index 159268a..11679d5 100644 --- a/include/webservices/manageurs.server.inc.php +++ b/include/webservices/manageurs.server.inc.php @@ -34,13 +34,14 @@ function get_annuaire_infos($method, $params) { FROM auth_user_md5 AS a INNER JOIN auth_user_quick AS q USING (user_id) WHERE a.matricule = {?}", $params[1]); + $array = $res->next(); } else{ $res = $globals->xdb->iterRow( "SELECT q.profile_mobile AS cell, a.naissance AS age, adr.adr1, adr.adr2, adr.adr3, adr.postcode, adr.city, adr.country, - adr.tel, adr.fax + adr.uid, adr.adrid FROM auth_user_md5 AS a INNER JOIN auth_user_quick AS q USING (user_id) LEFT JOIN adresses AS adr ON(adr.uid = a.user_id) @@ -49,25 +50,22 @@ function get_annuaire_infos($method, $params) { ORDER BY NOT FIND_IN_SET('active', adr.statut), FIND_IN_SET('res-secondaire', adr.statut), NOT FIND_IN_SET('courrier', adr.statut)", $params[1]); - - } - - //traitement des adresses si necessaire - if (isset($params[2])) { + //traitement des adresses si necessaire if(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'], - $adr['pays'], $adr['tel'], $adr['fax']) = $res->next()) + $adr['pays'], $uid, $adr['adrid']) = $res->next()) { $array['cell'] = $cell; $array['age'] = $age; $array['adresse'][] = $adr; + //on clamp le numero au nombre d'adresses dispo $adresse = min((int) $params[2], $res->total()); if ($adresse != 1) { //on ne veut pas la premiere adresse $i = 2; while(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'], - $adr['pays'], $adr['tel'], $adr['fax']) = $res->next()) + $adr['pays'], , $adr['adrid']) = $res->next()) { if($adresse == $i){//si on veut cette adresse en particulier $array['adresse'][0] = $adr; @@ -80,15 +78,37 @@ function get_annuaire_infos($method, $params) { $i++; } } + + // on rajoute les numéros de tél + $adrid_index = array(); + foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i; + // on rajoute les numéros de tels + $restel = $globals->xdb->iterator( + "SELECT t.tel, t.tel_type, t.adrid + FROM tels AS t + INNER JOIN adresses AS a ON (t.adrid = a.adrid AND t.uid = a.uid) + WHERE t.uid = {?} AND NOT FIND_IN_SET('pro', a.statut)", $uid); + while ($tel = $restel->next()) $array['adresse'][$adrid_index[$tel['adrid']]]['tels'][] = $tel; + foreach ($array['adresse'] as $i => $adr) { + unset($lasttel); + foreach($adr['tels'] as $j => $t){ + if (!isset($array['adresse'][$i]['tel']) && (strpos($t['tel_type'], 'Tél') === 0)) $array['adresse'][$i]['tel'] = $t['tel']; + elseif (!isset($array['adresse'][$i]['fax']) && (strpos($t['tel_type'], 'Fax') === 0)) $array['adresse'][$i]['fax'] = $t['tel']; + else $lasttel = $t['tel']; + if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) break; + } + if (!isset($array['adresse'][$i]['tel']) && isset($lasttel)) + $array['adresse'][$i]['tel'] = $lasttel; + elseif (!isset($array['adresse'][$i]['fax']) && isset($lasttel)) + $array['adresse'][$i]['fax'] = $lasttel; + unset($array['adresse'][$i]['adrid']); + unset($array['adresse'][$i]['tels']); + } } else{ $array = false; } } - else { //cas où on ne veut pas d'adresse - $array = $res->next(); - } - if ($array) { // on a bien eu un résultat : le matricule etait bon diff --git a/plugins/function.display_address.php b/plugins/function.display_address.php index 1ac3801..2a4f1a9 100644 --- a/plugins/function.display_address.php +++ b/plugins/function.display_address.php @@ -23,7 +23,11 @@ function smarty_function_display_address($param, &$smarty) { require_once('geoloc.inc.php'); $txtad = get_address_text($param['adr']); - if (!$txtad && !$param['adr']['tel'] && !$param['adr']['fax'] && !$param['adr']['mobile']) return ""; + if (!$txtad && + !$param['adr']['tels'] && !count($param['adr']['tels']) && + !$param['adr']['tel'] && + !$param['adr']['fax'] && + !$param['adr']['mobile']) return ""; $lines = explode("\n",$txtad); $txthtml = ""; @@ -44,6 +48,10 @@ function smarty_function_display_address($param, &$smarty) { $txthtml .= "
\nFax : \n".$param['adr']['fax']."\n
\n"; if ($param['adr']['mobile']) $txthtml .= "
\nTél : \n".$param['adr']['mobile']."\n
\n"; + if ($param['adr']['tels'] && count($param['adr']['tels'])) { + foreach ($param['adr']['tels'] as $tel) + $txthtml .= "
\n".$tel['tel_type']." : \n".$tel['tel']."\n
\n"; + } if (!$params['nodiv']) { $txthtml = "
\n".$txthtml."
\n"; diff --git a/templates/include/flags.radio.tpl b/templates/include/flags.radio.tpl index bdcada3..de93bed 100644 --- a/templates/include/flags.radio.tpl +++ b/templates/include/flags.radio.tpl @@ -19,7 +19,7 @@ {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} {* *} {**************************************************************************} - +{if $display neq "mini"} @@ -49,3 +49,14 @@
+{else} + + + + + + + + + +{/if} diff --git a/templates/profil/adresses.tpl b/templates/profil/adresses.tpl index aaf59d3..6b5d0fd 100644 --- a/templates/profil/adresses.tpl +++ b/templates/profil/adresses.tpl @@ -69,7 +69,7 @@ {include file="geoloc/form.address.tpl" adr=$adr titre=$titre url="`$smarty.server.PHP_SELF`?old_tab=`$smarty.request.old_tab`"} - Cette adresse est : + Adresse: @@ -97,23 +97,22 @@ on peut m'y envoyer du courrier par la poste - {include file="include/flags.radio.tpl" name="tel_pub[$adrid]" val=$adr.tel_pub} - - - Téléphone associé : - - - - - - - - Fax : - - - - - + {foreach from=$adr.tels item="tel"} + + + + {if $tel.new_tel} + + {/if} + {$tel.tel_type} : + + + + + + {include file="include/flags.radio.tpl" name="tel_pub`$tel.telid`[$adrid]" val=$tel.tel_pub display="mini"} + + {/foreach}   {/section}   diff --git a/templates/vcard.tpl b/templates/vcard.tpl index e600de6..188599e 100644 --- a/templates/vcard.tpl +++ b/templates/vcard.tpl @@ -57,13 +57,12 @@ ADR;TYPE=work;ENCODING=QUOTED-PRINTABLE:{format_adr adr=$vcard.adr_pro[0]} {/if} {foreach item=adr from=$vcard.adr} ADR;TYPE=home{if $adr.courier},postal{/if};ENCODING=QUOTED-PRINTABLE:{format_adr adr=$adr} -{if $adr.tel} -TEL;TYPE=home;ENCODING=QUOTED-PRINTABLE:{$adr.tel|qp_enc} -{/if} -{if $adr.fax} -FAX;TYPE=home;ENCODING=QUOTED-PRINTABLE:{$adr.fax|qp_enc} +{foreach item=tel from=$adr.tels} +{if $tel.tel} +{if $tel.tel_type neq 'Fax'}TEL{else}FAX{/if};TYPE=home;ENCODING=QUOTED-PRINTABLE:{$tel.tel|qp_enc} {/if} {/foreach} +{/foreach} {if $vcard.web} URL;ENCODING=QUOTED-PRINTABLE:{$vcard.web|qp_enc} {/if} diff --git a/upgrade/0.9.10/02_tels.sql b/upgrade/0.9.10/02_tels.sql new file mode 100644 index 0000000..6314401 --- /dev/null +++ b/upgrade/0.9.10/02_tels.sql @@ -0,0 +1,12 @@ +CREATE TABLE `tels` ( + `uid` smallint(5) unsigned NOT NULL default '0', + `adrid` tinyint(1) unsigned NOT NULL default '0', + `telid` tinyint(1) unsigned NOT NULL default '0', + `tel_type` varchar(20) NOT NULL default '', + `tel_pub` enum('private','ax','public') NOT NULL default 'private', + `tel` varchar(30) NOT NULL default '', + PRIMARY KEY (`uid`,`adrid`,`telid`) + ) +INSERT INTO tels SELECT uid, adrid, 0, 'Tél.', tel_pub, tel FROM adresses; +INSERT INTO tels SELECT uid, adrid, 1, 'Fax', tel_pub, fax FROM adresses; +DELETE FROM tels WHERE tel = ""; -- 2.1.4