- $this->settings['addresses'] = new ProfileAddress();
- $this->watched['addresses'] = true;
- }
-
- protected function _fetchData()
- {
- // 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,
- 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)
- WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut)
- ORDER BY adrid",
- S::i('uid'));
- if ($res->numRows() == 0) {
- $this->values['addresses'] = array();
- } else {
- $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",
- S::i('uid'));
- $i = 0;
- $adrNb = count($this->values['addresses']);
- while ($tel = $res->next()) {
- $adrid = $tel['adrid'];
- unset($tel['adrid']);
- while ($i < $adrNb && $this->values['addresses'][$i]['id'] < $adrid) {
- $i++;
- }
- if ($i >= $adrNb) {
- break;
- }
- $address =& $this->values['addresses'][$i];
- if (!isset($address['tel'])) {
- $address['tel'] = array();
- }
- if ($address['id'] == $adrid) {
- $address['tel'][] = $tel;
- }
- }
- foreach ($this->values['addresses'] as $id=>&$address) {
- if (!isset($address['tel'])) {
- $address['tel'] = array();
- }
- unset($address['id']);
- }