diff --git a/include/Contact.php b/include/Contact.php index 2aab828f8..ee5ec0cfc 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,7 +1,5 @@ 1) AND ($uid == 0) AND ($contactid != 0) AND ($url != "")) + if (count($contacts) > 1 AND $uid == 0 AND $contact_id != 0 AND $url != "") { q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d AND NOT `self`", dbesc(normalise_link($url)), - intval($contactid)); + intval($contact_id)); + } - require_once("Photo.php"); + require_once "Photo.php"; - update_contact_avatar($data["photo"],$uid,$contactid); + update_contact_avatar($data["photo"], $uid, $contact_id); - $r = q("SELECT `addr`, `alias`, `name`, `nick` FROM `contact` WHERE `id` = %d", intval($contactid)); + $contacts = q("SELECT `addr`, `alias`, `name`, `nick` FROM `contact` WHERE `id` = %d", intval($contact_id)); // This condition should always be true - if (!dbm::is_result($r)) - return $contactid; + if (!dbm::is_result($contacts)) { + return $contact_id; + } // Only update if there had something been changed - if (($data["addr"] != $r[0]["addr"]) OR - ($data["alias"] != $r[0]["alias"]) OR - ($data["name"] != $r[0]["name"]) OR - ($data["nick"] != $r[0]["nick"])) + if ($data["addr"] != $contacts[0]["addr"] OR + $data["alias"] != $contacts[0]["alias"] OR + $data["name"] != $contacts[0]["name"] OR + $data["nick"] != $contacts[0]["nick"]) { q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s', `name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d", dbesc($data["addr"]), @@ -649,10 +675,11 @@ function get_contact($url, $uid = 0, $no_update = false) { dbesc($data["nick"]), dbesc(datetime_convert()), dbesc(datetime_convert()), - intval($contactid) + intval($contact_id) ); + } - return $contactid; + return $contact_id; } /**