X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fdisplay.php;h=f879a91aeca49ec4a135d7ed36e7d80520c148f1;hb=f09cd571655bfd9966dd4529d4fb10256246a81c;hp=21fff7866c289f397fd18741f976edc3ed0aadda;hpb=b677f63e85c9b9d01a5022000ad6cfeaff1e6571;p=friendica.git diff --git a/mod/display.php b/mod/display.php index 21fff7866c..f879a91aec 100644 --- a/mod/display.php +++ b/mod/display.php @@ -112,6 +112,8 @@ function display_init(&$a) { function display_fetchauthor($a, $item) { + require_once("include/Contact.php"); + $profiledata = array(); $profiledata["uid"] = -1; $profiledata["nickname"] = $item["author-name"]; @@ -176,61 +178,9 @@ function display_fetchauthor($a, $item) { $profiledata["about"] = ""; } - // Don't show details from Diaspora contacts if you don't follow the contact - $showdetails = ($profiledata["network"] != NETWORK_DIASPORA); - - // Fetching further contact data from the contact table - $r = q("SELECT `uid`, `network`, `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords` - FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)", - dbesc(normalise_link($profiledata["url"])), intval(local_user()), dbesc($item["network"]), - intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND)); - if (!count($r)) - $r = q("SELECT `uid`, `network`, `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords` - FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `rel` IN (%d, %d)", - dbesc(normalise_link($profiledata["url"])), intval(local_user()), - intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND)); - - if (count($r)) { - $profiledata["name"] = $r[0]["name"]; - $profiledata["photo"] = $r[0]["photo"]; - $profiledata["nickname"] = $r[0]["nick"]; - $profiledata["addr"] = $r[0]["addr"]; - $profiledata["keywords"] = $r[0]["keywords"]; - $profiledata["network"] = $r[0]["network"]; - - if (local_user() OR $showdetails) { - $showdetails = true; - $profiledata["address"] = $r[0]["location"]; - $profiledata["about"] = $r[0]["about"]; - $profiledata["gender"] = $r[0]["gender"]; - } - } - - // Fetching profile data from global contacts - if ($profiledata["network"] != NETWORK_FEED) { - $r = q("SELECT `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`, `network` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profiledata["url"]))); - if (count($r)) { - $profiledata["name"] = $r[0]["name"]; - $profiledata["photo"] = $r[0]["photo"]; - $profiledata["nickname"] = $r[0]["nick"]; - $profiledata["addr"] = $r[0]["addr"]; - $profiledata["network"] = $r[0]["network"]; - - if ($r[0]["keywords"]) - $profiledata["keywords"] = $r[0]["keywords"]; - - if ($showdetails) { - if ($r[0]["location"]) - $profiledata["address"] = $r[0]["location"]; + $profiledata = get_contact_details_by_url($profiledata["url"], local_user(), $profiledata); - if ($r[0]["about"]) - $profiledata["about"] = $r[0]["about"]; - - if ($r[0]["gender"]) - $profiledata["gender"] = $r[0]["gender"]; - } - } - } + $profiledata["photo"] = App::remove_baseurl($profiledata["photo"]); if (local_user()) { if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) @@ -412,14 +362,7 @@ function display_content(&$a, $update = 0) { return ''; } - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` - WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` - AND NOT `item`.`moderated` + $r = q(item_query()." AND `item`.`uid` = %d AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d) $sql_extra ORDER BY `parent` DESC, `gravity` ASC, `id` ASC", @@ -427,6 +370,7 @@ function display_content(&$a, $update = 0) { intval($item_id) ); + if(!$r && local_user()) { // Check if this is another person's link to a post that we have $r = q("SELECT `item`.uri FROM `item` @@ -438,14 +382,7 @@ function display_content(&$a, $update = 0) { if($r) { $item_uri = $r[0]['uri']; - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` - WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` - AND NOT `item`.`moderated` + $r = q(item_query()." AND `item`.`uid` = %d AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d) ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", intval(local_user()), @@ -455,7 +392,6 @@ function display_content(&$a, $update = 0) { } } - if($r) { if((local_user()) && (local_user() == $a->profile['uid'])) { @@ -482,9 +418,7 @@ function display_content(&$a, $update = 0) { $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true)); $author_name = $r[0]["author-name"]; - $image = ""; - if ($image == "") - $image = $r[0]["thumb"]; + $image = $a->remove_baseurl($r[0]["thumb"]); if ($title == "") $title = $author_name;