]> git.mxchange.org Git - friendica.git/blobdiff - mod/dirfind.php
Merge remote-tracking branch 'upstream/develop' into 1606-contact-priority
[friendica.git] / mod / dirfind.php
index 44f70d641edccd729be3ab9d373791a30d15ea1b..0638fe14fa07438e204eeb266f896809e7ed4444 100644 (file)
@@ -66,16 +66,15 @@ function dirfind_content(&$a, $prefix = "") {
                        $objresult->tags = "";
                        $objresult->network = $user_data["network"];
 
-                       $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
-                                       dbesc(normalise_link($user_data["url"])), intval(local_user()));
-                       if ($contact)
-                               $objresult->cid = $contact[0]["id"];
-
+                       $contact = get_contact_details_by_url($user_data["url"], local_user());
+                       $objresult->cid = $contact["cid"];
 
                        $j->results[] = $objresult;
 
-                       poco_check($user_data["url"], $user_data["name"], $user_data["network"], $user_data["photo"],
-                               "", "", "", "", "", datetime_convert(), 0);
+                       // Add the contact to the global contacts if it isn't already in our system
+                       if (($contact["cid"] == 0) AND ($contact["zid"] == 0) AND ($contact["gid"] == 0))
+                               poco_check($user_data["url"], $user_data["name"], $user_data["network"], $user_data["photo"],
+                                       "", "", "", "", "", datetime_convert(), 0);
                } elseif ($local) {
 
                        if ($community)
@@ -100,6 +99,7 @@ function dirfind_content(&$a, $prefix = "") {
 
                        $count = q("SELECT count(*) AS `total` FROM `gcontact`
                                        LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
+                                               AND `contact`.`network` = `gcontact`.`network`
                                                AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
                                                AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
                                        WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
@@ -114,6 +114,7 @@ function dirfind_content(&$a, $prefix = "") {
                        $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`
                                        FROM `gcontact`
                                        LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
+                                               AND `contact`.`network` = `gcontact`.`network`
                                                AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
                                                AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
                                        WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND