From 5e4417a9f3f2dfa9ad9207de4022beeb14c797df Mon Sep 17 00:00:00 2001 From: Guillaume Bandet Date: Tue, 17 Jun 2008 12:52:33 +0200 Subject: [PATCH] Integrates new phone table in profile and other pages --- bin/cron/checkdb.php | 7 ++-- include/user.func.inc.php | 51 ++++++++++++++---------- include/webservices/manageurs.server.inc.php | 8 ++-- modules/payment/money/paypal.inc.php | 5 ++- modules/profile/addresses.inc.php | 26 +++++++------ modules/profile/general.inc.php | 23 ++++++++--- modules/profile/jobs.inc.php | 58 +++++++++++++++++++++------- modules/profile/page.inc.php | 11 +++++- plugins/function.display_address.php | 21 ++++++++-- templates/core/vcard.tpl | 2 +- templates/profile/adresses.tel.tpl | 6 ++- 11 files changed, 149 insertions(+), 69 deletions(-) diff --git a/bin/cron/checkdb.php b/bin/cron/checkdb.php index 818cf2a..fcb56b5 100755 --- a/bin/cron/checkdb.php +++ b/bin/cron/checkdb.php @@ -73,16 +73,15 @@ if ( PEAR::isError($opts) ) { /* Validite des flags de transmission */ check("SELECT u.user_id, nom, prenom, promo, - profile_mobile_pub, emails_alias_pub, profile_freetext_pub, profile_medals_pub + emails_alias_pub, profile_freetext_pub, profile_medals_pub FROM auth_user_md5 AS u INNER JOIN auth_user_quick AS q USING(user_id) - WHERE (profile_mobile_pub != 'private' AND profile_mobile_pub != 'ax' AND profile_mobile_pub != 'public') - OR (emails_alias_pub != 'private' AND emails_alias_pub != 'public') + WHERE (emails_alias_pub != 'private' AND emails_alias_pub != 'public') OR (profile_freetext_pub != 'private' AND profile_freetext_pub != 'public') OR (profile_medals_pub != 'private' AND profile_medals_pub != 'public')", "Utilisateur n'ayant pas de flag de publicite pour leurs donnees de profil"); check("select uid from adresses where pub != 'private' and pub !='ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour une adresse"); -check("select uid from tels where tel_pub != 'private' and tel_pub !='ax' and tel_pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de telephone"); +check("select uid from telephone where pub != 'private' and pub != 'ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de telephone"); check("select uid from profile_networking where pub != 'private' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicité pour une adresse de networking"); /* validite de aliases */ diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 4ff11ca..0f8b944 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -41,7 +41,7 @@ function user_clear_all_subs($user_id, $really_del=true) 'user_id' => array('requests', 'user_changes')); if ($really_del) { - array_push($tables_to_clear['uid'], 'emails', 'groupex.membres', 'contacts', 'adresses', 'tels', + array_push($tables_to_clear['uid'], 'emails', 'groupex.membres', 'contacts', 'adresses', 'telephone', 'photo', 'perte_pass', 'langues_ins', 'forums.abos', 'forums.profils'); array_push($tables_to_clear['user_id'], 'newsletter_ins', 'auth_user_quick', 'binets_ins'); $tables_to_clear['id'] = array('aliases'); @@ -264,14 +264,18 @@ function get_user_details_pro($uid, $view = 'private') { $sql = "SELECT e.entreprise, s.label as secteur , ss.label as sous_secteur , f.fonction_fr as fonction, e.poste, e.adr1, e.adr2, e.adr3, e.postcode, e.city, e.entrid, - gp.pays AS countrytxt, gr.name AS region, e.tel, e.fax, e.mobile, e.entrid, - e.pub, e.adr_pub, e.tel_pub, e.email, e.email_pub, e.web + gp.pays AS countrytxt, gr.name AS region, tt.display_tel AS tel, + tf.display_tel AS fax, tm.display_tel AS mobile, e.entrid, + e.pub, e.adr_pub, tt.pub AS tel_pub, e.email, e.email_pub, e.web FROM entreprises AS e LEFT JOIN emploi_secteur AS s ON(e.secteur = s.id) LEFT JOIN emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur) LEFT JOIN fonctions_def AS f ON(e.fonction = f.id) LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.country) LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.country and gr.region = e.region) + LEFT JOIN telephone AS tt ON(tt.uid = e.uid AND tt.link_type = 'pro' AND tt.link_id = entrid AND tt.tel_id = 0) + LEFT JOIN telephone AS tf ON(tf.uid = e.uid AND tf.link_type = 'pro' AND tf.link_id = entrid AND tf.tel_id = 1) + LEFT JOIN telephone AS tm ON(tm.uid = e.uid AND tm.link_type = 'pro' AND tm.link_id = entrid AND tm.tel_id = 2) WHERE e.uid = {?} ORDER BY e.entrid"; $res = XDB::query($sql, $uid); @@ -362,11 +366,10 @@ function get_user_details_adr($uid, $view = 'private') { $adrid_index[$adr['adrid']] = $i; } - $sql = "SELECT t.adrid, t.tel_pub, t.tel_type, t.tel, t.telid - 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"; + $sql = "SELECT link_id AS adrid, pub AS tel_pub, tel_type, display_tel AS tel, tel_id + FROM telephone AS t + WHERE uid = {?} AND link_type = 'address' + ORDER BY link_id, tel_type DESC, tel_id"; $restel = XDB::iterator($sql, $uid); while ($nexttel = $restel->next()) { if (has_user_right($nexttel['tel_pub'], $view)) { @@ -390,8 +393,8 @@ function &get_user_details($login, $from_uid = '', $view = 'private') { $reqsql = "SELECT u.user_id, u.promo, u.promo_sortie, u.prenom, u.nom, u.nom_usage, u.date, u.cv, u.perms IN ('admin','user','disabled') AS inscrit, FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces, - q.profile_nick AS nickname, q.profile_from_ax, q.profile_mobile AS mobile, q.profile_freetext AS freetext, - q.profile_mobile_pub AS mobile_pub, q.profile_freetext_pub AS freetext_pub, + q.profile_nick AS nickname, q.profile_from_ax, t.display_tel AS mobile, q.profile_freetext AS freetext, + t.pub AS mobile_pub, q.profile_freetext_pub AS freetext_pub, q.profile_medals_pub AS medals_pub, IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166, a.alias AS forlife, a2.alias AS bestalias, @@ -410,6 +413,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') LEFT JOIN photo AS p ON (p.uid = u.user_id) LEFT JOIN mentor AS m ON (m.uid = u.user_id) LEFT JOIN emails AS e ON (e.uid = u.user_id AND e.flags='active') + LEFT JOIN telephone AS t ON (t.uid = u.user_id AND link_type = 'user' AND link_id = 0 AND tel_id = 0) WHERE a.alias = {?} GROUP BY u.user_id"; $res = XDB::query($reqsql, $from_uid, $login); @@ -540,7 +544,7 @@ function update_user_address($uid, $adrid, $adr) { $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['postcode'], $adr['city'], $adr['pub'], $adrid, $uid); if (isset($adr['tels']) && is_array($adr['tels'])) { - $res = XDB::query("SELECT telid FROM tels WHERE uid = {?} AND adrid = {?} ORDER BY telid", $uid, $adrid); + $res = XDB::query("SELECT tel_id FROM telephone WHERE uid = {?} AND link_type = 'address' AND link_id = {?} ORDER BY tel_id", $uid, $adrid); $telids = $res->fetchColumn(); foreach ($adr['tels'] as $tel) { if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) { @@ -559,28 +563,33 @@ function update_user_address($uid, $adrid, $adr) { // {{{ function remove_user_address() function remove_user_address($uid, $adrid) { XDB::execute("DELETE FROM adresses WHERE adrid = {?} AND uid = {?}", $adrid, $uid); - XDB::execute("DELETE FROM tels WHERE adrid = {?} AND uid = {?}", $adrid, $uid); + XDB::execute("DELETE FROM telephone WHERE adrid = {?} AND uid = {?} AND link_type = 'address'", $adrid, $uid); } // }}} // {{{ function add_user_tel() function add_user_tel($uid, $adrid, $telid, $tel) { - XDB::execute( - "INSERT INTO tels SET uid = {?}, adrid = {?}, telid = {?}, tel = {?}, tel_type = {?}, tel_pub = {?}", - $uid, $adrid, $telid, $tel['tel'], $tel['tel_type'], $tel['tel_pub']); + require('profil.func.inc.php'); + $fmt_phone = format_phone_number($tel['tel']); + $disp_phone = format_display_number($fmt_phone, $error); + XDB::execute("INSERT INTO telephone (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub) + VALUES ({?}, 'address', {?}, {?}, {?}, {?}, {?}, {?})", + $uid, $adrid, $telid, $tel['tel_type'], $fmt_phone, $disp_phone, $tel['tel_pub']); } // }}} // {{{ function update_user_tel() function update_user_tel($uid, $adrid, $telid, $tel) { - XDB::execute( - "UPDATE tels SET tel = {?}, tel_type = {?}, tel_pub = {?} - WHERE telid = {?} AND adrid = {?} AND uid = {?}", - $tel['tel'], $tel['tel_type'], $tel['tel_pub'], - $telid, $adrid, $uid); + require('profil.func.inc.php'); + $fmt_phone = format_phone_number($tel['tel']); + $disp_phone = format_display_number($fmt_phone, $error); + XDB::execute("UPDATE telephone SET search_tel = {?}, display_tel = {?}, tel_type = {?}, pub = {?} + WHERE link_type = 'address' AND tel_id = {?} AND link_id = {?} AND uid = {?}", + $fmt_phone, $disp_phone, $tel['tel_type'], $tel['tel_pub'], + $telid, $adrid, $uid); } // }}} // {{{ function remove_user_tel() function remove_user_tel($uid, $adrid, $telid) { - XDB::execute("DELETE FROM tels WHERE telid = {?} AND adrid = {?} AND uid = {?}", + XDB::execute("DELETE FROM telephone WHERE tel_id = {?} AND link_id = {?} AND uid = {?} AND link_type = 'address'", $telid, $adrid, $uid); } // }}} diff --git a/include/webservices/manageurs.server.inc.php b/include/webservices/manageurs.server.inc.php index 50a5854..bed509a 100644 --- a/include/webservices/manageurs.server.inc.php +++ b/include/webservices/manageurs.server.inc.php @@ -81,10 +81,10 @@ function get_annuaire_infos($method, $params) { foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i; // on rajoute les numéros de tels $restel = 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); + "SELECT t.display_tel AS tel, t.tel_type, t.link_id as adrid + FROM telephone AS t + INNER JOIN adresses AS a ON (t.link_id = a.adrid AND t.uid = a.uid) + WHERE t.uid = {?} AND t.link_type = 'address' 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); diff --git a/modules/payment/money/paypal.inc.php b/modules/payment/money/paypal.inc.php index 48e740f..465ead1 100644 --- a/modules/payment/money/paypal.inc.php +++ b/modules/payment/money/paypal.inc.php @@ -80,10 +80,11 @@ class PayPal $res = XDB::query( "SELECT a.adr1 AS address1, a.adr2 AS address2, a.city, a.postcode AS zip, a.country, - IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b + IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b FROM auth_user_quick AS q LEFT JOIN adresses AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut)) - LEFT JOIN tels AS t ON (t.uid = a.uid AND t.adrid = a.adrid) + LEFT JOIN telephone AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address' AND t1.link_id = a.adrid) + LEFT JOIN telephone AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user' AND t2.link_id = 0) WHERE q.user_id = {?} LIMIT 1", S::v('uid')); $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc())); diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index 1e518aa..7458d3e 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -44,6 +44,10 @@ class ProfileAddress extends ProfileGeoloc } else { $tel['pub'] = $this->pub->value($page, 'pub', $tel['pub'], $s); $tel['tel'] = $this->tel->value($page, 'tel', $tel['tel'], $s); + if(!isset($tel['type']) || ($tel['type'] != 'fixed' && $tel['type'] != 'mobile' && $tel['type'] != 'fax')) { + $tel['type'] = 'fixed'; + $s = false; + } if (!$s) { $tel['error'] = true; $success = false; @@ -107,12 +111,12 @@ class ProfileAddress extends ProfileGeoloc private function saveTel($adrid, $telid, array &$tel) { - XDB::execute("INSERT INTO tels (uid, adrid, telid, - tel_type, tel_pub, tel) - VALUES ({?}, {?}, {?}, + XDB::execute("INSERT INTO telephone (uid, link_type, link_id, tel_id, tel_type, + search_tel, display_tel, pub) + VALUES ({?}, 'address', {?}, {?}, {?}, {?}, {?}, {?})", - S::i('uid'), $adrid, $telid, - $tel['type'], $tel['pub'], $tel['tel']); + S::i('uid'), $adrid, $telid, $tel['type'], + format_phone_number($tel['tel']), $tel['tel'], $tel['pub']); } private function saveAddress($adrid, array &$address) @@ -159,8 +163,8 @@ class ProfileAddress extends ProfileGeoloc XDB::execute("DELETE FROM adresses WHERE uid = {?}", S::i('uid')); - XDB::execute("DELETE FROM tels - WHERE uid = {?}", + XDB::execute("DELETE FROM telephone + WHERE uid = {?} AND link_type = 'address'", S::i('uid')); foreach ($value as $adrid=>&$address) { $this->saveAddress($adrid, $address); @@ -204,10 +208,10 @@ class ProfileAddresses extends ProfilePage $this->values['addresses'] = $res->fetchAllAssoc(); } - $res = XDB::iterator("SELECT adrid, tel_type AS type, tel_pub AS pub, tel - FROM tels - WHERE uid = {?} - ORDER BY adrid", + $res = XDB::iterator("SELECT link_id AS adrid, tel_type AS type, pub, display_tel AS tel + FROM telephone + WHERE uid = {?} AND link_type = 'address' + ORDER BY link_id", S::i('uid')); $i = 0; $adrNb = count($this->values['addresses']); diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 8942d4a..ccff9a1 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -259,7 +259,7 @@ class ProfileGeneral extends ProfilePage { // Checkout all data... $res = XDB::query("SELECT u.promo, u.promo_sortie, u.nom_usage, u.nationalite, u.naissance, - q.profile_mobile as mobile, q.profile_mobile_pub as mobile_pub, + t.display_tel as mobile, t.pub as mobile_pub, d.email_directory as email_directory, q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub, q.profile_nick as nick, q.profile_from_ax as synchro_ax, u.matricule_ax, @@ -270,6 +270,7 @@ class ProfileGeneral extends ProfilePage FROM auth_user_md5 AS u INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id) INNER JOIN profile_names_display AS n ON(n.user_id = u.user_id) + LEFT JOIN telephone AS t ON(u.user_id = t.uid AND link_type = 'user') LEFT JOIN profile_directory AS d ON(d.uid = u.user_id) LEFT JOIN applis_ins AS a1 ON(a1.uid = u.user_id and a1.ordre = 0) LEFT JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1) @@ -318,15 +319,13 @@ class ProfileGeneral extends ProfilePage preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']), S::v('uid')); } - if ($this->changed['nick'] || $this->changed['mobile'] || $this->changed['mobile_pub'] - || $this->changed['freetext'] - || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) { + if ($this->changed['nick'] || $this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) { XDB::execute("UPDATE auth_user_quick - SET profile_nick= {?}, profile_mobile={?}, profile_mobile_pub={?}, + SET profile_nick= {?}, profile_freetext={?}, profile_freetext_pub={?}, profile_from_ax = {?} WHERE user_id = {?}", - $this->values['nick'], $this->values['mobile'], $this->values['mobile_pub'], + $this->values['nick'], $this->values['freetext'], $this->values['freetext_pub'], $this->values['synchro_ax'], S::v('uid')); } @@ -337,6 +336,18 @@ class ProfileGeneral extends ProfilePage VALUES ({?}, {?})", S::v('uid'), $new_email); } + if ($this->changed['mobile'] || $this->changed['mobile_pub']) { + require_once('profil.func.inc.php'); + $fmt_phone = format_phone_number($this->values['mobile']); + XDB::execute("DELETE FROM telephone + WHERE uid = {?} AND link_type = 'user'", + S::v('uid')); + if ($fmt_phone != '') { + XDB::execute("INSERT INTO telephone (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub) + VALUES ({?}, 'user', '0', '0', 'mobile', {?}, {?}, {?})", + S::v('uid'), $fmt_phone, $this->values['mobile'], $this->values['mobile_pub']); + } + } if ($this->changed['nick']) { require_once('user.func.inc.php'); user_reindex(S::v('uid')); diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 4f0d428..051b6e8 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -101,9 +101,13 @@ class ProfileJob extends ProfileGeoloc public function save(ProfilePage &$page, $field, $value) { + require_once('profil.func.inc.php'); XDB::execute("DELETE FROM entreprises WHERE uid = {?}", S::i('uid')); + XDB::execute("DELETE FROM telephone + WHERE uid = {?} AND link_type = 'pro'", + S::i('uid')); $i = 0; foreach ($value as &$job) { if ($job['email'] == "new@new.new") { @@ -113,24 +117,46 @@ class ProfileJob extends ProfileGeoloc XDB::execute("INSERT INTO entreprises (uid, entrid, entreprise, secteur, ss_secteur, fonction, poste, adr1, adr2, adr3, postcode, city, cityid, country, region, regiontxt, - tel, fax, mobile, email, web, - pub, adr_pub, tel_pub, email_pub, flags, + email, web, + pub, adr_pub, email_pub, flags, glat, glng) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, - {?}, {?}, {?}, {?}, {?}, - {?}, {?}, {?}, {?}, {?}, + {?}, {?}, + {?}, {?}, {?}, {?}, {?}, {?})", - S::i('uid'), $i++, $job['name'], $job['secteur'], $job['ss_secteur'], + S::i('uid'), $i, $job['name'], $job['secteur'], $job['ss_secteur'], $job['fonction'], $job['poste'], $job['adr']['adr1'], $job['adr']['adr2'], $job['adr']['adr3'], $job['adr']['postcode'], $job['adr']['city'], $job['adr']['cityid'], $job['adr']['country'], $job['adr']['region'], $job['adr']['regiontxt'], - $job['tel'], $job['fax'], $job['mobile'], $job['email'], $job['web'], - $job['pub'], $job['adr']['pub'], $job['tel_pub'], $job['email_pub'], + $job['email'], $job['web'], + $job['pub'], $job['adr']['pub'], $job['email_pub'], $job['adr']['checked'] ? 'geoloc' : '', $job['adr']['precise_lat'], $job['adr']['precise_lon']); + if ($job['tel'] != '') { + XDB::execute("INSERT INTO telephone (uid, link_type, link_id, tel_id, + tel_type, search_tel, display_tel, pub) + VALUES ({?}, 'pro', {?}, 0, + 'fixed', {?}, {?}, {?})", + S::i('uid'), $i, format_phone_number($job['tel']), $job['tel'], $job['tel_pub']); + } + if ($job['fax'] != '') { + XDB::execute("INSERT INTO telephone (uid, link_type, link_id, tel_id, + tel_type, search_tel, display_tel, pub) + VALUES ({?}, 'pro', {?}, 1, + 'fax', {?}, {?}, {?})", + S::i('uid'), $i, format_phone_number($job['fax']), $job['fax'], $job['tel_pub']); + } + if ($job['mobile'] != '') { + XDB::execute("INSERT INTO telephone (uid, link_type, link_id, tel_id, + tel_type, search_tel, display_tel, pub) + VALUES ({?}, 'pro', {?}, 2, + 'mobile', {?}, {?}, {?})", + S::i('uid'), $i, format_phone_number($job['mobile']), $job['mobile'], $job['tel_pub']); + } + $i++; } } } @@ -162,19 +188,25 @@ class ProfileJobs extends ProfilePage e.postcode, e.city, e.cityid, e.region, e.regiontxt, e.country, gp.pays, gp.display, FIND_IN_SET('geoloc', flags), - e.tel, e.fax, e.mobile, e.email, e.web, e.pub, - e.adr_pub, e.tel_pub, e.email_pub, - e.glat AS precise_lat, e.glng AS precise_lon + e.email, e.web, e.pub, + e.adr_pub, e.email_pub, + e.glat AS precise_lat, e.glng AS precise_lon, + tt.display_tel AS tel, tt.pub AS tel_pub, + tf.display_tel AS fax, tm.display_tel AS mobile FROM entreprises AS e LEFT JOIN geoloc_pays AS gp ON(gp.a2 = e.country) - WHERE uid = {?} AND entreprise != '' + LEFT JOIN telephone AS tt ON(tt.uid = e.uid AND tt.link_type = 'pro' AND tt.link_id = entrid AND tt.tel_id = 0) + LEFT JOIN telephone AS tf ON(tf.uid = e.uid AND tf.link_type = 'pro' AND tf.link_id = entrid AND tf.tel_id = 1) + LEFT JOIN telephone AS tm ON(tm.uid = e.uid AND tm.link_type = 'pro' AND tm.link_id = entrid AND tm.tel_id = 2) + WHERE e.uid = {?} AND entreprise != '' ORDER BY entrid", S::i('uid')); $this->values['jobs'] = array(); while (list($name, $secteur, $ss_secteur, $fonction, $poste, $adr1, $adr2, $adr3, $postcode, $city, $cityid, $region, $regiontxt, $country, $countrytxt, $display, - $checked, $tel, $fax, $mobile, $email, $web, - $pub, $adr_pub, $tel_pub, $email_pub, $glat, $glng) = $res->next()) { + $checked, $email, $web, + $pub, $adr_pub, $email_pub, $glat, $glng, + $tel, $tel_pub, $fax, $mobile) = $res->next()) { $this->values['jobs'][] = array('name' => $name, 'secteur' => $secteur, 'ss_secteur' => $ss_secteur, diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index 4b4df1d..64ba191 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -104,10 +104,17 @@ class ProfileTel extends ProfileNoSave if (is_null($value)) { return isset($page->values[$field]) ? $page->values[$field] : S::v($field); } - $success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches); + require_once('profil.func.inc.php'); + $value = format_phone_number($value); + if($value == '') { + $success = true; + return $value; + } + $value = format_display_number($value,$error); + $success = !$error; if (!$success) { global $page; - $page->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0])); + $page->trigError('Le préfixe international du numéro de téléphone est inconnu. '); } return $value; } diff --git a/plugins/function.display_address.php b/plugins/function.display_address.php index 98dfdef..6a632ad 100644 --- a/plugins/function.display_address.php +++ b/plugins/function.display_address.php @@ -46,7 +46,6 @@ function smarty_function_display_address($param, &$smarty) !$param['adr']['fax'] && !$param['adr']['mobile']) return ""; - $lines = explode("\n", $txtad); $idt = array_shift($lines); $restore = true; @@ -94,10 +93,24 @@ function smarty_function_display_address($param, &$smarty) if ($param['adr']['fax']) $txthtml .= "
\nFax : \n".$param['adr']['fax']."\n
\n"; if ($param['adr']['mobile']) - $txthtml .= "
\nTél : \n".$param['adr']['mobile']."\n
\n"; + $txthtml .= "
\nMob : \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"; + foreach ($param['adr']['tels'] as $tel) { + switch ($tel['tel_type']) { + case 'fixed': + $tel_type = 'Tél'; + break; + case 'fax': + $tel_type = 'Fax'; + break; + case 'mobile': + $tel_type = 'Mob'; + break; + default: + $tel_type = $tel['tel_type']; + } + $txthtml .= "
\n" . $tel_type . " : \n" . $tel['tel'] . "\n
\n"; + } } if (!$param['nodiv']) { $pos = $param['pos'] ? " style='float: " . $param['pos'] . "'" : ''; diff --git a/templates/core/vcard.tpl b/templates/core/vcard.tpl index f6bef39..53c720c 100644 --- a/templates/core/vcard.tpl +++ b/templates/core/vcard.tpl @@ -65,7 +65,7 @@ ADR;TYPE=work:{format_adr adr=$vcard.adr_pro[0]} ADR;TYPE=home{if $adr.courier},postal{/if}:{format_adr adr=$adr} {foreach item=tel from=$adr.tels} {if $tel.tel} -{if $tel.tel_type neq 'Fax'}TEL{else}FAX{/if};TYPE=home:{$tel.tel} +{if $tel.tel_type neq 'fax'}TEL{else}FAX{/if};TYPE=home:{$tel.tel} {/if} {/foreach} {/foreach} diff --git a/templates/profile/adresses.tel.tpl b/templates/profile/adresses.tel.tpl index 60c0391..f9922dc 100644 --- a/templates/profile/adresses.tel.tpl +++ b/templates/profile/adresses.tel.tpl @@ -27,7 +27,11 @@ N°{$t+1} - + {icon name=cross title="Supprimer ce numéro de téléphone"} -- 2.1.4