- $res = XDB::query(
- "SELECT a.text, l.name AS city, a.postalCode AS zip, a.countryiId AS country,
- IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
- FROM auth_user_quick AS q
- LEFT JOIN profile_addresses AS a ON (q.user_id = a.pid AND FIND_IN_SET('current', a.flags))
- LEFT JOIN profile_phones AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address'
- AND t1.link_id = a.adrid)
- LEFT JOIN profile_phones AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user'
- AND t2.link_id = 0)
- LEFT JOIN geoloc_localities AS l ON (l.id = a.localityId)
- WHERE q.user_id = {?}
- LIMIT 1",
- S::v('uid'));
- $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
- list($this->infos['client']['address1'], $this->infos['client']['address2']) =
- explode("\n", Geocoder::getFirstLines($this->infos['client']['text'],
- $this->infos['client']['zip'], 2));
- unset($this->infos['client']['text']);
+ if ($user->hasProfile()) {
+ $res = XDB::query("SELECT pa.text, GROUP_CONCAT(pace2.short_name) AS city,
+ GROUP_CONCAT(pace3.short_name) AS zip, GROUP_CONCAT(pace1.short_name) AS country,
+ IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b
+ FROM profile_addresses AS pa
+ LEFT JOIN profile_phones AS pp1 ON (pp1.pid = pa.pid AND pp1.link_type = 'address' AND pp1.link_id = pa.id)
+ LEFT JOIN profile_phones AS pp2 ON (pp2.pid = pa.pid AND pp2.link_type = 'user' AND pp2.link_id = 0)
+ LEFT JOIN profile_addresses_components AS pc ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid
+ AND pa.type = pc.type AND pa.id = pc.id)
+ LEFT JOIN profile_addresses_components_enum AS pace1 ON (FIND_IN_SET('country', pace1.types) AND pace1.id = pc.component_id)
+ LEFT JOIN profile_addresses_components_enum AS pace2 ON (FIND_IN_SET('locality', pace2.types) AND pace2.id = pc.component_id)
+ LEFT JOIN profile_addresses_components_enum AS pace3 ON (FIND_IN_SET('postal_code', pace3.types) AND pace3.id = pc.component_id)
+ WHERE pa.pid = {?} AND FIND_IN_SET('current', pa.flags)
+ GROUP BY pa.pid, pa.jobid, pa.groupid, pa.id, pa.type
+ LIMIT 1",
+ $user->profile()->id());
+ $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
+ list($this->infos['client']['address1'], $this->infos['client']['address2']) =
+ explode("\n", Geocoder::getFirstLines($this->infos['client']['text'],
+ $this->infos['client']['zip'], 2));
+ unset($this->infos['client']['text']);
+ } else {
+ $this->infos['client'] = replace_accent($info_client);
+ }