Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
}
-function addTel(id)
+function addTel(prefid, prefname)
{
var i = 0;
- var adid = 'addresses_' + id;
- var tel = adid + '_tel_';
- while (document.getElementById(tel + i) != null) {
+ var prefix = prefid + '_';
+ while (document.getElementById(prefix + i) != null) {
i++;
}
- $('#' + adid + '_add_tel').before('<div id="' + tel + i + '" style="clear: both"></div>');
- Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i);
+ $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
+ Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
}
+function removeTel(id)
+{
+ $('#' + id).remove();
+}
+
+function addPhoneComment(id, pref)
+{
+ document.getElementById(id+'_comment').style.display = '';
+ document.getElementById(id+'_addComment').style.display = 'none';
+}
+
+function removePhoneComment(id, pref)
+{
+ document.getElementById(id+'_comment').style.display = 'none';
+ document.forms.prof_annu[pref+ '[comment]'].value = '';
+ document.getElementById(id+'_addComment').style.display = '';
+}
// Geoloc
}
function same_tel(&$a, &$b) {
- $numbera = preg_replace('/[^0-9]/', '', (string) $a);
- $numberb = preg_replace('/[^0-9]/', '', (string) $b);
+ $numbera = format_phone_number((string) $a);
+ $numberb = format_phone_number((string) $b);
return $numbera === $numberb;
}
function same_address(&$a, &$b) {
return
(same_field($a['adr1'],$b['adr1'])) &&
- (same_field($a['adr1'],$b['adr1'])) &&
- (same_field($a['adr1'],$b['adr1'])) &&
+ (same_field($a['adr2'],$b['adr2'])) &&
+ (same_field($a['adr3'],$b['adr3'])) &&
(same_field($a['postcode'],$b['postcode'])) &&
(same_field($a['city'],$b['city'])) &&
(same_field($a['countrytxt'],$b['countrytxt'])) &&
substr($tel, 0, 1), substr($tel, 0, 2), substr($tel, 0, 3));
if ($res->numRows() == 0) {
$error = true;
- return '*+' . $tel;
+ return '+' . $tel;
}
$format = $res->fetchOneAssoc();
}
{
$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, 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
+ gp.pays AS countrytxt, gr.name AS region, e.entrid,
+ e.pub, e.adr_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 profile_phones AS tt ON(tt.uid = e.uid AND tt.link_type = 'pro' AND tt.link_id = entrid AND tt.tel_id = 0)
- LEFT JOIN profile_phones AS tf ON(tf.uid = e.uid AND tf.link_type = 'pro' AND tf.link_id = entrid AND tf.tel_id = 1)
- LEFT JOIN profile_phones 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);
$all_pro[$i]['region'] = '';
}
}
- if (!has_user_right($pro['tel_pub'], $view)) {
- // if no tel was defined, then the viewer will be able to write it
- if ($pro['tel'] == '' &&
- $pro['fax'] == '' &&
- $pro['mobile'] == '') {
- $all_pro[$i]['tel_pub'] = $view;
- } else {
- $all_pro[$i]['tel'] = '';
- $all_pro[$i]['fax'] = '';
- $all_pro[$i]['mobile'] = '';
+ $sql = "SELECT pub AS tel_pub, tel_type, display_tel AS tel, comment
+ FROM profile_phones AS t
+ WHERE uid = {?} AND link_type = 'pro' AND link_id = {?}
+ ORDER BY link_id, tel_type DESC, tel_id";
+ $restel = XDB::iterator($sql, $uid, $pro['entrid']);
+ while ($nexttel = $restel->next()) {
+ if (has_user_right($nexttel['tel_pub'], $view)) {
+ if (!isset($all_pro[$i]['tels'])) {
+ $all_pro[$i]['tels'] = array($nexttel);
+ } else {
+ $all_pro[$i]['tels'][] = $nexttel;
+ }
}
}
if (!has_user_right($pro['email_pub'], $view)) {
$all_pro[$i]['fonction'] == '' &&
$all_pro[$i]['secteur'] == '' &&
$all_pro[$i]['poste'] == '' &&
- $all_pro[$i]['tel'] == '' &&
- $all_pro[$i]['fax'] == '' &&
- $all_pro[$i]['mobile'] == '' &&
+ (!isset($all_pro[$i]['tels'])) &&
$all_pro[$i]['email'] == '')
unset($all_pro[$i]);
}
$adrid_index[$adr['adrid']] = $i;
}
- $sql = "SELECT link_id AS adrid, pub AS tel_pub, tel_type, display_tel AS tel, tel_id AS telid
+ $sql = "SELECT link_id AS adrid, pub AS tel_pub, tel_type, display_tel AS tel, tel_id AS telid, comment
FROM profile_phones AS t
WHERE uid = {?} AND link_type = 'address'
ORDER BY link_id, tel_type DESC, tel_id";
{
$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, t.display_tel AS mobile, q.profile_freetext AS freetext,
- t.pub AS mobile_pub, q.profile_freetext_pub AS freetext_pub,
+ q.profile_nick AS nickname, q.profile_from_ax, q.profile_freetext AS freetext,
+ 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,
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 profile_phones 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);
$user['nickname'] = '';
$user['section'] = '';
}
- // hide mobile
- if (!has_user_right($user['mobile_pub'], $view)) {
- if ($user['mobile'] == '')
- $user['mobile_pub'] = $view;
- else
- $user['mobile'] = '';
- }
// hide freetext
if (!has_user_right($user['freetext_pub'], $view)) {
$user['freetext'] = '';
}
+ $sql = "SELECT pub AS tel_pub, tel_type, display_tel AS tel, comment
+ FROM profile_phones AS t
+ WHERE uid = {?} AND link_type = 'user'
+ ORDER BY tel_type DESC, tel_id";
+ $restel = XDB::iterator($sql, $uid);
+ while ($nexttel = $restel->next()) {
+ if (has_user_right($nexttel['tel_pub'], $view)) {
+ if (!isset($user['tels'])) {
+ $user['tels'] = array($nexttel);
+ } else {
+ $user['tels'][] = $nexttel;
+ }
+ }
+ }
+
$user['adr_pro'] = get_user_details_pro($uid, $view);
$user['adr'] = get_user_details_adr($uid, $view);
$page->assign('adr', array());
}
- function handler_ajax_tel(&$page, $adid, $telid)
+ function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
{
header('Content-Type: text/html; charset=utf-8');
- $page->changeTpl('profile/adresses.tel.tpl', NO_SKIN);
- $page->assign('i', $adid);
- $page->assign('adid', "addresses_$adid");
- $page->assign('adpref', "addresses[$adid]");
- $page->assign('t', $telid);
+ $page->changeTpl('profile/phone.tpl', NO_SKIN);
+ $page->assign('prefid', $prefid);
+ $page->assign('prefname', $prefname);
+ $page->assign('telid', $telid);
$page->assign('tel', array());
}
{
private $bool;
private $pub;
- private $tel;
public function __construct()
{
$this->bool = new ProfileBool();
$this->pub = new ProfilePub();
- $this->tel = new ProfileTel();
}
- private function cleanAddress(ProfilePage &$page, array &$address, &$success)
+ private function cleanAddress(ProfilePage &$page, $adrid, array &$address, &$success)
{
if (@$address['changed']) {
$address['datemaj'] = time();
}
$success = true;
- foreach ($address['tel'] as $t=>&$tel) {
- if (@$tel['removed'] || !trim($tel['tel'])) {
- unset($address['tel'][$t]);
- } 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;
- }
- }
- unset($tel['removed']);
+ if (!isset($address['tel'])) {
+ $address['tel'] = array();
}
+ $profiletel = new ProfilePhones('address', $adrid);
+ $address['tel'] = $profiletel->value($page, 'tel', $address['tel'], $s);
$address['checked'] = $this->bool->value($page, 'checked', $address['checked'], $s);
$address['secondaire'] = $this->bool->value($page, 'secondaire', $address['secondaire'], $s);
$address['mail'] = $this->bool->value($page, 'mail', $address['mail'], $s);
$ls = true;
$this->geolocAddress($adr, $s);
$ls = ($ls && $s);
- $this->cleanAddress($page, $adr, $s);
+ $this->cleanAddress($page, $key, $adr, $s);
$ls = ($ls && $s);
if (!trim($adr['text'])) {
unset($value[$key]);
$address['country'], $address['region'], $address['regiontxt'],
$address['pub'], $address['datemaj'], $flags,
S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon'], $address['comment']);
- foreach ($address['tel'] as $telid=>&$tel) {
- $this->saveTel($adrid, $telid, $tel);
- }
}
public function save(ProfilePage &$page, $field, $value)
S::i('uid'));
foreach ($value as $adrid=>&$address) {
$this->saveAddress($adrid, $address);
+ $profiletel = new ProfilePhones('address', $adrid);
+ $profiletel->saveTels('tel', $address['tel']);
}
}
}
$this->values['addresses'] = $res->fetchAllAssoc();
}
- $res = XDB::iterator("SELECT link_id AS adrid, tel_type AS type, pub, display_tel AS tel
+ $res = XDB::iterator("SELECT link_id AS adrid, tel_type AS type, pub, display_tel AS tel, comment
FROM profile_phones
WHERE uid = {?} AND link_type = 'address'
ORDER BY link_id",
$this->settings['nom'] = $this->settings['prenom']
= new ProfileNom();
$this->settings['naissance'] = new ProfileDate();
- $this->settings['mobile_pub']
- = $this->settings['freetext_pub']
+ $this->settings['freetext_pub']
= $this->settings['photo_pub']
= new ProfilePub();
$this->settings['freetext']
= null;
$this->settings['synchro_ax']
= new ProfileBool();
- $this->settings['mobile'] = new ProfileTel();
$this->settings['email_directory']
= new ProfileEmail();
$this->settings['email_directory_new']
= new ProfileEmailDirectory();
$this->settings['networking'] = new ProfileNetworking();
+ $this->settings['tels'] = new ProfilePhones('user', 0);
$this->settings['appli1']
= $this->settings['appli2']
= new ProfileAppli();
- $this->watched= array('nom' => true, 'freetext' => true, 'mobile' => true,
+ $this->watched= array('nom' => true, 'freetext' => true, 'tels' => true,
'networking' => true, 'appli1' => true, 'appli2' => true,
'nationalite' => true, 'nick' => true);
}
WHERE sn.user_id = {?}
ORDER BY sn.name_type, search_score, search_name",
S::v('uid'));
+
+ // Retreive phones
+ $res = XDB::iterator("SELECT t.display_tel AS tel, t.tel_type AS type, t.pub, t.comment
+ FROM profile_phones AS t
+ WHERE t.uid = {?} AND t.link_type = 'user'
+ ORDER BY t.tel_id",
+ S::v('uid'));
+ $this->values['tels'] = $res->fetchAllAssoc();
}
protected function _saveData()
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 profile_phones
- WHERE uid = {?} AND link_type = 'user'",
- S::v('uid'));
- if ($fmt_phone != '') {
- XDB::execute("INSERT INTO profile_phones (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'));
private $mail_new;
private $mail;
private $web;
- private $tel;
private $bool;
private $checks;
= $this->mail_new
= new ProfileEmail();
$this->web = new ProfileWeb();
- $this->tel = new ProfileTel();
$this->bool = new ProfileBool();
$this->checks = array('web' => array('web'),
'mail_new' => array('email_new'),
'mail' => array('email'),
- 'tel' => array('tel', 'fax', 'mobile'),
- 'pub' => array('pub', 'tel_pub', 'email_pub'));
+ 'pub' => array('pub', 'email_pub'));
}
- private function cleanJob(ProfilePage &$page, array &$job, &$success)
+ private function cleanJob(ProfilePage &$page,$jobid, array &$job, &$success)
{
$success = true;
foreach ($this->checks as $obj=>&$fields) {
}
$job['adr']['pub'] = $this->pub->value($page, 'adr_pub', @$job['adr']['pub'], $s);
$job['adr']['checked'] = $this->bool->value($page, 'adr_checked', @$job['adr']['checked'], $s);
+ if (!isset($job['tel'])) {
+ $job['tel'] = array();
+ }
+ $profiletel = new ProfilePhones('pro', $jobid);
+ $job['tel'] = $profiletel->value($page, 'tel', $job['tel'], $s);
unset($job['removed']);
unset($job['new']);
unset($job['adr']['changed']);
$ls = true;
$this->geolocAddress($job['adr'], $s);
$ls = ($ls && $s);
- $this->cleanJob($page, $job, $s);
+ $this->cleanJob($page, $key, $job, $s);
$ls = ($ls && $s);
if (!$init) {
$success = ($success && $ls);
WHERE uid = {?} AND link_type = 'pro'",
S::i('uid'));
$i = 0;
- foreach ($value as &$job) {
+ foreach ($value as $jobid=>&$job) {
if ($job['email'] == "new@new.new") {
$job['email'] = $job['email_new'];
}
-
XDB::execute("INSERT INTO entreprises (uid, entrid, entreprise, secteur, ss_secteur,
fonction, poste, adr1, adr2, adr3, postcode,
city, cityid, country, region, regiontxt,
$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 profile_phones (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 profile_phones (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 profile_phones (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']);
- }
+ $profiletel = new ProfilePhones('pro', $jobid);
+ $profiletel->saveTels('tel', $job['tel']);
$i++;
}
}
$this->values['cv'] = $res->fetchOneCell();
// Build the jobs tree
- $res = XDB::iterRow("SELECT e.entreprise, e.secteur, e.ss_secteur,
+ $res = XDB::iterRow("SELECT e.entrid, e.entreprise, e.secteur, e.ss_secteur,
e.fonction, e.poste, e.adr1, e.adr2, e.adr3,
e.postcode, e.city, e.cityid, e.region, e.regiontxt,
e.country, gp.pays, gp.display,
FIND_IN_SET('geoloc', flags),
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
+ e.glat AS precise_lat, e.glng AS precise_lon
FROM entreprises AS e
LEFT JOIN geoloc_pays AS gp ON(gp.a2 = e.country)
- LEFT JOIN profile_phones AS tt ON(tt.uid = e.uid AND tt.link_type = 'pro' AND tt.link_id = entrid AND tt.tel_id = 0)
- LEFT JOIN profile_phones AS tf ON(tf.uid = e.uid AND tf.link_type = 'pro' AND tf.link_id = entrid AND tf.tel_id = 1)
- LEFT JOIN profile_phones 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,
+ while (list($id, $name, $secteur, $ss_secteur, $fonction, $poste,
$adr1, $adr2, $adr3, $postcode, $city, $cityid,
$region, $regiontxt, $country, $countrytxt, $display,
$checked, $email, $web,
- $pub, $adr_pub, $email_pub, $glat, $glng,
- $tel, $tel_pub, $fax, $mobile) = $res->next()) {
- $this->values['jobs'][] = array('name' => $name,
+ $pub, $adr_pub, $email_pub, $glat, $glng
+ ) = $res->next()) {
+ $this->values['jobs'][] = array('id' => $id,
+ 'name' => $name,
'secteur' => $secteur,
'ss_secteur' => $ss_secteur,
'fonction' => $fonction,
'checked' => $checked,
'precise_lat'=> $glat,
'precise_lon'=> $glng),
- 'tel' => $tel,
- 'fax' => $fax,
- 'mobile' => $mobile,
'email' => $email,
'web' => $web,
'pub' => $pub,
- 'tel_pub' => $tel_pub,
'email_pub' => $email_pub);
}
+
+ $res = XDB::iterator("SELECT link_id AS jobid, tel_type AS type, pub, display_tel AS tel, comment
+ FROM profile_phones
+ WHERE uid = {?} AND link_type = 'pro'
+ ORDER BY link_id",
+ S::i('uid'));
+ $i = 0;
+ $jobNb = count($this->values['jobs']);
+ while ($tel = $res->next()) {
+ $jobid = $tel['jobid'];
+ unset($tel['jobid']);
+ while ($i < $jobNb && $this->values['jobs'][$i]['id'] < $jobid) {
+ $i++;
+ }
+ if ($i >= $jobNb) {
+ break;
+ }
+ $job =& $this->values['jobs'][$i];
+ if (!isset($job['tel'])) {
+ $job['tel'] = array();
+ }
+ if ($job['id'] == $jobid) {
+ $job['tel'][] = $tel;
+ }
+ }
+ foreach ($this->values['jobs'] as $id=>&$job) {
+ if (!isset($job['tel'])) {
+ $job['tel'] = array();
+ }
+ unset($job['id']);
+ }
}
protected function _saveData()
}
}
+class ProfilePhones implements ProfileSetting
+{
+ private $tel;
+ private $pub;
+ protected $link_type;
+ protected $link_id;
+
+ public function __construct($type, $id)
+ {
+ $this->tel = new ProfileTel();
+ $this->pub = new ProfilePub();
+ $this->link_type = $type;
+ $this->link_id = $id;
+ }
+
+ public function value(ProfilePage &$page, $field, $value, &$success)
+ {
+ $success = true;
+ if (is_null($value)) {
+ $value = isset($page->values[$field]) ? $page->values[$field] : array();
+ }
+ if (!is_array($value)) {
+ $value = array();
+ }
+ foreach ($value as $key=>&$phone) {
+ if (@$phone['removed']) {
+ unset($value[$key]);
+ } else {
+ $phone['pub'] = $this->pub->value($page, 'pub', $phone['pub'], $s);
+ $phone['tel'] = $this->tel->value($page, 'tel', $phone['tel'], $s);
+ if(!isset($phone['type']) || ($phone['type'] != 'fixed' && $phone['type'] != 'mobile' && $phone['type'] != 'fax')) {
+ $phone['type'] = 'fixed';
+ $s = false;
+ }
+ if (!$s) {
+ $phone['error'] = true;
+ $success = false;
+ }
+ if (!isset($phone['comment'])) {
+ $phone['comment'] = '';
+ }
+ }
+ }
+ return $value;
+ }
+
+ private function saveTel($telid, array &$phone)
+ {
+ if ($phone['tel'] != '') {
+ XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type,
+ search_tel, display_tel, pub, comment)
+ VALUES ({?}, {?}, {?}, {?}, {?},
+ {?}, {?}, {?}, {?})",
+ S::i('uid'), $this->link_type, $this->link_id, $telid, $phone['type'],
+ format_phone_number($phone['tel']), $phone['tel'], $phone['pub'], $phone['comment']);
+ }
+ }
+
+ public function save(ProfilePage &$page, $field, $value)
+ {
+ XDB::execute("DELETE FROM profile_phones
+ WHERE uid = {?} AND link_type = {?} AND link_id = {?}",
+ S::i('uid'), $this->link_type, $this->link_id);
+ $this->saveTels($field, $value);
+ }
+
+ //Only saves phones without a delete operation
+ public function saveTels($field, $value)
+ {
+ foreach ($value as $telid=>&$phone) {
+ $this->saveTel($telid, $phone);
+ }
+ }
+}
+
class ProfilePub extends ProfileNoSave
{
public function value(ProfilePage &$page, $field, $value, &$success)
{
require_once('geoloc.inc.php');
$txtad = get_address_text($param['adr']);
- if (!$txtad &&
- !$param['adr']['tels'] && !count($param['adr']['tels']) &&
- !$param['adr']['tel'] &&
- !$param['adr']['fax'] &&
- !$param['adr']['mobile']) return "";
+ if (!$txtad && !$param['adr']['tels'] && !count($param['adr']['tels'])) {
+ return "";
+ }
$lines = explode("\n", $txtad);
$idt = array_shift($lines);
{
$txthtml .= "<strong>".$line."</strong><br/>\n";
}
- if ($param['adr']['tel'])
- $txthtml .= "<div>\n<em>Tél : </em>\n<strong>".$param['adr']['tel']."</strong>\n</div>\n";
- if ($param['adr']['fax'])
- $txthtml .= "<div>\n<em>Fax : </em>\n<strong>".$param['adr']['fax']."</strong>\n</div>\n";
- if ($param['adr']['mobile'])
- $txthtml .= "<div>\n<em>Mob : </em>\n<strong>".$param['adr']['mobile']."</strong>\n</div>\n";
- if ($param['adr']['tels'] && count($param['adr']['tels'])) {
- 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 .= "<div>\n<em>" . $tel_type . " : </em>\n<strong>" . $tel['tel'] . "</strong>\n</div>\n";
- }
+ if(isset($param['adr']['tels'])) {
+ require_once('function.display_phones.php');
+ $txthtml .= smarty_function_display_phones($param['adr'],$smarty);
}
if (!$param['nodiv']) {
$pos = $param['pos'] ? " style='float: " . $param['pos'] . "'" : '';
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+function smarty_function_display_phones($param, &$smarty)
+{
+ $txthtml = "";
+ if (count($param['tels'])) {
+ foreach ($param['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 .= "<div>\n<em>" . $tel_type . " : </em>\n<strong>" . $tel['tel'] . "</strong>\n";
+ $comment = "";
+ if ($tel['comment'] != "") {
+ $commentHtml = str_replace(array('&', '"'), array('&', '"'), $tel['comment']);
+ $commentJs = str_replace(array('\\', '\''), array('\\\\', '\\\''), $commentHtml);
+ $txthtml .= "<img style=\"margin-left: 5px;\" src=\"images/icons/comments.gif\""
+ . " onmouseover=\"return overlib('"
+ . $commentJs
+ . "',WIDTH,250);\""
+ . " onmouseout=\"nd();\""
+ . " alt=\"Commentaire\" title=\""
+ . $commentHtml
+ . "\"/>\n";
+ }
+ $txthtml .= "</div>\n";
+ }
+ }
+ return $txthtml;
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
{if $vcard.virtualalias}
EMAIL;TYPE=internet:{$vcard.virtualalias}
{/if}
-{if $vcard.mobile}
-TEL;TYPE=cell:{$vcard.mobile|vcard_enc}
+{if $vcard.tels}
+{foreach item=tel from=$vcard.tels}
+{if $tel.tel_type eq 'mobile'}TEL;TYPE=cell{else}{if $tel.tel_type eq 'fax'}FAX{else}TEL{/if};TYPE=home{/if}:{$tel.tel|vcard_enc}
+{/foreach}
{/if}
{if $vcard.adr_pro}
{if $vcard.adr_pro[0].entreprise}
{if $vcard.adr_pro[0].fonction}
ROLE:{$vcard.adr_pro[0].fonction|vcard_enc}
{/if}
-{if $vcard.adr_pro[0].tel}
-TEL;TYPE=work:{$vcard.adr_pro[0].tel|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].fax}
-FAX;TYPE=work:{$vcard.adr_pro[0].fax|vcard_enc}
+{if $vcard.adr_pro[0].tels}
+{foreach item=tel from=$vcard.adr_pro[0].tels}
+{if $tel.tel_type eq 'mobile'}TEL;TYPE=cell,work{else}{if $tel.tel_type eq 'fax'}FAX{else}TEL{/if};TYPE=work{/if}:{$tel.tel|vcard_enc}
+{/foreach}
{/if}
ADR;TYPE=work:{format_adr adr=$vcard.adr_pro[0]}
{/if}
{foreach item=adr from=$vcard.adr}
ADR;TYPE=home{if $adr.courier},postal{/if}:{format_adr adr=$adr}
+{if $adr.tels}
{foreach item=tel from=$adr.tels}
-{if $tel.tel}
-{if $tel.tel_type neq 'fax'}TEL{else}FAX{/if};TYPE=home:{$tel.tel}
-{/if}
+{if $tel.tel_type eq 'mobile'}TEL;TYPE=cell,home{else}{if $tel.tel_type eq 'fax'}FAX{else}TEL{/if};TYPE=home{/if}:{$tel.tel|vcard_enc}
{/foreach}
+{/if}
{/foreach}
{foreach from=$vcard.networking item=nw}
{if $nw.filter eq 'web'}
<tr class="pair">
<td>
{foreach from=$adr.tel key=t item=tel}
- <div id="{"`$adid`_tel_`$t`"}" style="clear: both">
- {include file="profile/adresses.tel.tpl" t=$t tel=$tel}
- </div>
+ <div id="{"`$adid`_tel_`$t`"}" style="clear: both">
+ {include file="profile/phone.tpl" prefname="`$adpref`[tel]" prefid="`$adid`_tel" telid=$t tel=$tel}
+ </div>
{/foreach}
{if $adr.tel|@count eq 0}
- <div id="{"`$adid`_tel_0"}" style="clear: both">
- {include file="profile/adresses.tel.tpl" t=0 tel=0}
- </div>
+ <div id="{"`$adid`_tel_0"}" style="clear: both">
+ {include file="profile/phone.tpl" prefname="`$adpref`[tel]" prefid="`$adid`_tel" telid=0 tel=0}
+ </div>
{/if}
- <div id="{$adid}_add_tel" class="center" style="clear: both">
- <a href="javascript:addTel({$i})">
+ <div id="{$adid}_tel_add" class="center" style="clear: both; padding-top: 4px">
+ <a href="javascript:addTel('{$adid}_tel', '{$adpref}[tel]')">
{icon name=add title="Ajouter un numéro de téléphone"} Ajouter un numéro de téléphone
</a>
</div>
</th>
</tr>
<tr>
- <td>
- <span class="titre">Téléphone mobile</span>
+ <td colspan="2">
+ <span class="titre">Téléphones personnels</span>
</td>
- <td>
- <input type="text" size="18" maxlength="18" name="mobile"
- {if $errors.mobile}class="error"{/if} value="{$mobile}" />
- <span class="flags">
- {include file="include/flags.radio.tpl" name="mobile_pub" val=$mobile_pub}
- </span>
+ </tr>
+ <tr>
+ <td colspan="2">
+ {foreach from=$tels key=telid item=tel}
+ <div id="tels_{$telid}" style="clear: both; padding-top: 4px; padding-bottom: 4px">
+ {include file="profile/phone.tpl" prefname='tels' prefid='tels' telid=$telid tel=$tel}
+ </div>
+ {/foreach}
+ {if $tels|@count eq 0}
+ <div id="tels_0" style="clear: both; padding-top: 4px; padding-bottom: 4px">
+ {include file="profile/phone.tpl" prefname='tels' preid='tels' telid=0 tel=0}
+ </div>
+ {/if}
+ <div id="tels_add" class="center" style="clear: both; padding-top: 4px;">
+ <a href="javascript:addTel('tels', 'tels');">
+ {icon name=add title="Ajouter un téléphone"}Ajouter un téléphone
+ </a>
+ </div>
</td>
</tr>
{if $email_error}
{include file="geoloc/form.address.tpl" name="`$jobpref`[adr]" id="`$jobid`_adr" adr=$job.adr}
</div>
</div>
- <div style="float: right; width: 50%">
- <div class="titre">Téléphone</div>
- <div class="flags">
- {include file="include/flags.radio.tpl" name="`$jobpref`[tel_pub]" val=$job.tel_pub}
+ </td>
+ </tr>
+ <tr class="pair">
+ <td colspan="2">
+ {foreach from=$job.tel key=t item=tel}
+ <div id="{"`$jobid`_tel_`$t`"}" style="clear: both">
+ {include file="profile/phone.tpl" prefname="`$jobpref`[tel]" prefid="`$jobid`_tel" telid=$t tel=$tel}
+ </div>
+ {/foreach}
+ {if $job.tel|@count eq 0}
+ <div id="{"`$jobid`_tel_0"}" style="clear: both">
+ {include file="profile/phone.tpl" prefname="`$jobpref`[tel]" prefid="`$jobid`_tel" telid=0 tel=0}
</div>
- <table style="clear: both">
- <tr>
- <td>Bureau :</td>
- <td>
- <input type="text" size="18" maxlength="18" {if $job.tel_error}class="error"{/if}
- name="{$jobpref}[tel]" value="{$job.tel}" />
- </td>
- </tr>
- <tr>
- <td>Fax :</td>
- <td>
- <input type="text" size="18" maxlength="18" {if $job.fax_error}class="error"{/if}
- name="{$jobpref}[fax]" value="{$job.fax}" /></td>
- </tr>
- <tr>
- <td>Mobile :</td>
- <td>
- <input type="text" size="18" maxlength="18" {if $job.mobile_error}class="error"{/if}
- name="{$jobpref}[mobile]" value="{$job.mobile}" />
- </td>
- </tr>
- </table>
+ {/if}
+ <div id="{$jobid}_tel_add" class="center" style="clear: both; padding-top: 4px;">
+ <a href="javascript:addTel('{$jobid}_tel', '{$jobpref}[tel]')">
+ {icon name=add title="Ajouter un numéro de téléphone"} Ajouter un numéro de téléphone
+ </a>
</div>
</td>
</tr>
{* *}
{**************************************************************************}
-{assign var=telpref value="`$adpref`[tel][`$t`]"}
-{assign var=telid value="`$adid`_tel_`$t`"}
+{assign var=telpref value="`$prefname`[`$telid`]"}
+{assign var=id value="`$prefid`_`$telid`"}
+<div class="titre" style="float: left; width: 2.5em">N°{$telid+1}</div>
+<div style="float: left;">
+ <select name="{$telpref}[type]">
+ <option value="fixed"{if $tel.type eq 'fixed'} selected="selected"{/if}>Fixe</option>
+ <option value="mobile"{if $tel.type eq 'mobile'} selected="selected"{/if}>Mobile</option>
+ <option value="fax"{if $tel.type eq 'fax'} selected="selected"{/if}>Fax</option>
+ </select>
+ <input type="hidden" name="{$telpref}[removed]" value="0"/>
+ <input type="text" size="19" maxlength="28" name="{$telpref}[tel]" {if $tel.error}class="error"{/if} value="{$tel.tel}" />
+ <a href="javascript:removeTel('{$id}')">
+ {icon name=cross title="Supprimer ce numéro de téléphone"}
+ </a>
+ <a id="{$id}_addComment" href="javascript:addPhoneComment('{$id}', '{$telpref}')" {if $tel.comment neq ''}style="display:none" {/if}>
+ {icon name=comments title="Ajouter un commentaire"}
+ </a>
+</div>
<div style="float: right" class="flags">
{include file="include/flags.radio.tpl" name="`$telpref`[pub]" val=$tel.pub}
</div>
-<span class="titre">N°{$t+1}</span>
-<input type="hidden" name="{$telpref}[removed]" value="0" />
-<select name="{$telpref}[type]">
- <option value="fixed"{if $tel.type eq 'fixed'} selected="selected"{/if}>Fixe</option>
- <option value="mobile"{if $tel.type eq 'mobile'} selected="selected"{/if}>Mobile</option>
- <option value="fax"{if $tel.type eq 'fax'} selected="selected"{/if}>Fax</option>
-</select>
-<input type="text" size="19" maxlength="28" name="{$telpref}[tel]" {if $tel.error}class="error"{/if} value="{$tel.tel}" />
-<a href="javascript:removeObject('{$telid}', '{$telpref}')">
- {icon name=cross title="Supprimer ce numéro de téléphone"}
-</a>
-
+<div id="{$id}_comment" style="clear: both;{if $tel.comment eq ''} display:none{/if}">
+ Commentaire :
+ <input type="text" size="45" maxlength="80" name="{$telpref}[comment]" {if $tel.error}class="error"{/if} value="{$tel.comment}"/>
+ <a href="javascript:removePhoneComment('{$id}', '{$telpref}')">
+ {icon name=cross title="Supprimer le commentaire"}
+ </a>
+</div>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
le {$x.date|date_format}
</div>
{/if}
- {if $logged || $x.mobile}
+ {if $logged || $x.tels}
<div class="contact">
{if $logged}
<div class='email'>
{/if}
</div>
{/if}
- {if $x.mobile}
- <div class="mob">
- <em class="intitule">Mobile : </em>{$x.mobile}
- </div>
+ {if $x.tels}
+ {display_phones tels=$x.tels}
{/if}
<div class='spacer'></div>
</div>
`search_tel` varchar(25) NOT NULL COMMENT 'search number in an international format with only digits and the initial +',
`display_tel` varchar(30) NOT NULL COMMENT 'display number',
`pub` enum('private', 'ax', 'public') NOT NULL DEFAULT 'private',
+ `comment` varchar(80) NOT NULL,
PRIMARY KEY(`uid`, `link_type`, `link_id`, `tel_id`),
INDEX (`search_tel`)
);