- if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
- // Is it in format @user@domain.tld or @http://domain.tld/...?
-
- // First check the contact table for the address
- $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify`, `forum`, `prv` FROM `contact`
- WHERE `addr` = '%s' AND `uid` = %d AND
- (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
- LIMIT 1",
- dbesc($name),
- intval($profile_uid),
- dbesc(NETWORK_OSTATUS)
- );
-
- // Then check in the contact table for the url
- if (!DBM::is_result($r)) {
- $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify`, `forum`, `prv` FROM `contact`
- WHERE `nurl` = '%s' AND `uid` = %d AND
- (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
- LIMIT 1",
- dbesc(normalise_link($name)),
- intval($profile_uid),
- dbesc(NETWORK_OSTATUS)
- );
- }
-
- // Then check in the global contacts for the address
- if (!DBM::is_result($r)) {
- $r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
- WHERE `addr` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
- LIMIT 1",
- dbesc($name),
- dbesc(NETWORK_OSTATUS)
- );
- }
-
- // Then check in the global contacts for the url
- if (!DBM::is_result($r)) {
- $r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
- WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
- LIMIT 1",
- dbesc(normalise_link($name)),
- dbesc(NETWORK_OSTATUS)
- );
- }
-
- if (!DBM::is_result($r)) {
- $probed = Probe::uri($name);
- if ($result['network'] != NETWORK_PHANTOM) {
- GContact::update($probed);
- $r = q("SELECT `url`, `name`, `nick`, `network`, `alias`, `notify` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
- dbesc(normalise_link($probed["url"])));
- }
- }
+ if (strpos($name, 'http://')) {
+ // At first we have to ensure that the contact exists
+ Contact::getIdForURL($name);
+
+ // Now we should have something
+ $contact = Contact::getDetailsByURL($name);
+ } elseif (strpos($name, '@')) {
+ // This function automatically probes when no entry was found
+ $contact = Contact::getDetailsByAddr($name);