X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Faddresses.inc.php;h=2fe7a8d4c08749f6c3039cb5ed1affe8034aaaa5;hb=b1797f70e5a49dbd238f16746410d3a4ed1c68ff;hp=feb369211c5108f513a88c3e556add56f11453df;hpb=a619333a5db46a8833599faf37177b2a99b03d59;p=platal.git diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index feb3692..2fe7a8d 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -1,6 +1,6 @@ tel = new ProfileTel(); } - private function geolocAddress(array &$address, &$success) - { - require_once 'geoloc.inc.php'; - $success = true; - unset($address['geoloc']); - unset($address['geoloc_cityid']); - if (@$address['parsevalid'] || (@$address['text'] && @$address['changed']) || !@$address['cityid']) { - $address = array_merge($address, empty_address()); - $new = get_address_infos(@$address['text']); - if (compare_addresses_text(@$adress['text'], $geotxt = get_address_text($new)) - || @$address['parsevalid']) { - $address = array_merge($address, $new); - } else { - $success = false; - $address = array_merge($address, cut_address(@$address['text'])); - $address['geoloc'] = $geotxt; - $address['geoloc_cityid'] = $new['cityid']; - } - } - if (@$address['changed']) { - $address['datemaj'] = time(); - } - $address['text'] = get_address_text($address); - } - private function cleanAddress(ProfilePage &$page, array &$address, &$success) { if (@$address['changed']) { @@ -76,9 +51,7 @@ class ProfileAddress } unset($tel['removed']); } - if (@$address['changed']) { - $address['datemaj'] = time(); - } + $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); $address['temporary'] = $this->bool->value($page, 'temporary', $address['temporary'], $s); @@ -103,15 +76,19 @@ class ProfileAddress } } $current = 0; + $success = true; foreach ($value as $key=>&$adr) { if (@$adr['current']) { $current++; } } - if (!$init && $current != 1 && count($value) > 0) { + if ($current == 0 && count($value) > 0) { + foreach ($value as $key=>&$adr) { + $adr['current'] = true; + break; + } + } else if ($current > 1) { $success = false; - } else { - $success = true; } foreach ($value as $key=>&$adr) { $ls = true; @@ -153,22 +130,25 @@ class ProfileAddress if ($address['current']) { $flags[] = 'active'; } + if ($address['checked']) { + $flags[] = 'coord-checked'; + } $flags = implode(',', $flags); XDB::execute("INSERT INTO adresses (adr1, adr2, adr3, postcode, city, cityid, country, region, regiontxt, pub, datemaj, statut, - uid, adrid) + uid, adrid, glat, glng) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, FROM_UNIXTIME({?}), {?}, - {?}, {?})", + {?}, {?}, {?}, {?})", $address['adr1'], $address['adr2'], $address['adr3'], $address['postcode'], $address['city'], $address['cityid'], $address['country'], $address['region'], $address['regiontxt'], $address['pub'], $address['datemaj'], $flags, - S::i('uid'), $adrid); + S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon']); foreach ($address['tel'] as $telid=>&$tel) { $this->saveTel($adrid, $telid, $tel); } @@ -196,25 +176,24 @@ class ProfileAddresses extends ProfilePage { parent::__construct($wiz); $this->settings['addresses'] = new ProfileAddress(); + $this->watched['addresses'] = true; } - protected function fetchData() + protected function _fetchData() { - if (count($this->orig) > 0) { - $this->values = $this->orig; - return; - } // Build the addresses tree $res = XDB::query("SELECT a.adrid AS id, a.adr1, a.adr2, a.adr3, UNIX_TIMESTAMP(a.datemaj) AS datemaj, a.postcode, a.city, a.cityid, a.region, a.regiontxt, a.pub, a.country, gp.pays AS countrytxt, gp.display, + FIND_IN_SET('coord-checked', a.statut) AS checked, FIND_IN_SET('res-secondaire', a.statut) AS secondaire, FIND_IN_SET('courrier', a.statut) AS mail, FIND_IN_SET('temporaire', a.statut) AS temporary, - FIND_IN_SET('active', a.statut) AS current + FIND_IN_SET('active', a.statut) AS current, + a.glat AS precise_lat, a.glng AS precise_lon FROM adresses AS a - INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country) + INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country) WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut) ORDER BY adrid", S::i('uid')); @@ -254,7 +233,6 @@ class ProfileAddresses extends ProfilePage } unset($address['id']); } - parent::fetchData(); } }