- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
- intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
- dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET));
- if (dbm::is_result($r)) {
- $contact = $r[0];
- $author["contact-id"] = $r[0]["id"];
- } else {
- $author["contact-id"] = $contact["id"];
+ $author["contact-id"] = $contact["id"];
+
+ if ($author["author-link"] != "") {
+ if ($aliaslink == "") {
+ $aliaslink = $author["author-link"];
+ }
+
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
+ intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
+ dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET));
+
+ if (dbm::is_result($r)) {
+ $contact = $r[0];
+ $author["contact-id"] = $r[0]["id"];
+ $author["author-link"] = $r[0]["url"];
+ }
+ } elseif ($addr != "") {
+ // Should not happen
+ $contact = dba::fetch_first("SELECT * FROM `contact` WHERE `uid` = ? AND `addr` = ? AND `network` != ?",
+ $importer["uid"], $addr, NETWORK_STATUSNET);
+
+ if (dbm::is_result($contact)) {
+ $author["contact-id"] = $contact["id"];
+ $author["author-link"] = $contact["url"];
+ }