- //traitement des adresses si necessaire
- if (isset($params[2])) {
- if(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
- $adr['pays'], $adr['tel'], $adr['fax']) = $res->next())
- {
- $array['cell'] = $cell;
+ // We check we actually have an identification number.
+ if(!empty($params[1])) {
+ // We only retrieve addresses when required.
+ if(!isset($params[2])) {
+ $res = XDB::iterRow("SELECT pp.display_tel AS cell, p.birthdate AS age
+ FROM profiles AS p
+ LEFT JOIN profile_phones AS pp ON (pp.pid = p.pid AND pp.link_type = 'user'
+ AND pp.tel_type = 'mobile')
+ WHERE p.xorg_id = {?} LIMIT 1",
+ $params[1]);
+ $array = $res->next();
+ } else {
+ $res = XDB::iterRow("SELECT p.birthdate, pa.text, pa.postalCode
+ gl.name, pa.countryId, p.pid, pa.id
+ FROM profiles AS p
+ LEFT JOIN profile_addresses AS pa ON (pa.pid = p.pid)
+ LEFT JOIN geoloc_localities AS gl ON (pl.id = pa.localityId)
+ WHERE p.xorg_id = {?} AND NOT FIND_IN_SET('job', pa.flags)
+ ORDER BY NOT FIND_IN_SET('current', pa.flags),
+ FIND_IN_SET('secondary', pa.flags),
+ NOT FIND_IN_SET('mail', pa.flags)",
+ $params[1]);
+ // Process the addresses we got.
+ if(list($age, $text, $adr['cp'], $adr['ville'],
+ $adr['pays'], $pid, $adr['adrid']) = $res->next()) {
+ list($adr['adr1'], $adr['adr2'], $adr['adr3']) =
+ explode("\n", Geocoder::getFirstLines($text, $adr['cp'], 3));
+ $sql = XDB::query("SELECT display_tel
+ FROM profile_phones
+ WHERE pid = {?} AND link_type = 'user' AND tel_type = 'mobile'
+ LIMIT 1", $pid);
+ if ($sql->numRows() > 0) {
+ $array['cell'] = $sql->fetchOneCell();
+ } else {
+ $array['cell'] ='';
+ }