The plink in Diaspora posts now links to the correct place
This commit is contained in:
parent
dd45dcbef3
commit
e8a2c68647
|
@ -1183,7 +1183,7 @@ class Diaspora {
|
||||||
* @return array the item record
|
* @return array the item record
|
||||||
*/
|
*/
|
||||||
private static function parent_item($uid, $guid, $author, $contact) {
|
private static function parent_item($uid, $guid, $author, $contact) {
|
||||||
$r = q("SELECT `id`, `parent`, `body`, `wall`, `uri`, `private`, `origin`,
|
$r = q("SELECT `id`, `parent`, `body`, `wall`, `uri`, `guid`, `private`, `origin`,
|
||||||
`author-name`, `author-link`, `author-avatar`,
|
`author-name`, `author-link`, `author-avatar`,
|
||||||
`owner-name`, `owner-link`, `owner-avatar`
|
`owner-name`, `owner-link`, `owner-avatar`
|
||||||
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
|
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
|
||||||
|
@ -1266,26 +1266,38 @@ class Diaspora {
|
||||||
*
|
*
|
||||||
* @return string the post link
|
* @return string the post link
|
||||||
*/
|
*/
|
||||||
private static function plink($addr, $guid) {
|
private static function plink($addr, $guid, $parent_guid = '') {
|
||||||
$r = q("SELECT `url`, `nick`, `network` FROM `fcontact` WHERE `addr`='%s' LIMIT 1", dbesc($addr));
|
$r = q("SELECT `url`, `nick`, `network` FROM `fcontact` WHERE `addr`='%s' LIMIT 1", dbesc($addr));
|
||||||
|
|
||||||
// Fallback
|
// Fallback
|
||||||
if (!$r)
|
if (!dbm::is_result($r)) {
|
||||||
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$guid;
|
if ($parent_guid != '') {
|
||||||
|
return "https://".substr($addr,strpos($addr,"@") + 1)."/posts/".$parent_guid."#".$guid;
|
||||||
|
} else {
|
||||||
|
return "https://".substr($addr,strpos($addr,"@") + 1)."/posts/".$guid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Friendica contacts are often detected as Diaspora contacts in the "fcontact" table
|
// Friendica contacts are often detected as Diaspora contacts in the "fcontact" table
|
||||||
// So we try another way as well.
|
// So we try another way as well.
|
||||||
$s = q("SELECT `network` FROM `gcontact` WHERE `nurl`='%s' LIMIT 1", dbesc(normalise_link($r[0]["url"])));
|
$s = q("SELECT `network` FROM `gcontact` WHERE `nurl`='%s' LIMIT 1", dbesc(normalise_link($r[0]["url"])));
|
||||||
if ($s)
|
if (dbm::is_result($s)) {
|
||||||
$r[0]["network"] = $s[0]["network"];
|
$r[0]["network"] = $s[0]["network"];
|
||||||
|
}
|
||||||
|
|
||||||
if ($r[0]["network"] == NETWORK_DFRN)
|
if ($r[0]["network"] == NETWORK_DFRN) {
|
||||||
return(str_replace("/profile/".$r[0]["nick"]."/", "/display/".$guid, $r[0]["url"]."/"));
|
return str_replace("/profile/".$r[0]["nick"]."/", "/display/".$guid, $r[0]["url"]."/");
|
||||||
|
}
|
||||||
|
|
||||||
if (self::is_redmatrix($r[0]["url"]))
|
if (self::is_redmatrix($r[0]["url"])) {
|
||||||
return $r[0]["url"]."/?f=&mid=".$guid;
|
return $r[0]["url"]."/?f=&mid=".$guid;
|
||||||
|
}
|
||||||
|
|
||||||
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$guid;
|
if ($parent_guid != '') {
|
||||||
|
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$parent_guid."#".$guid;
|
||||||
|
} else {
|
||||||
|
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$guid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1459,6 +1471,8 @@ class Diaspora {
|
||||||
|
|
||||||
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
||||||
|
|
||||||
|
$datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
|
||||||
|
|
||||||
$body = diaspora2bb($text);
|
$body = diaspora2bb($text);
|
||||||
|
|
||||||
$datarray["body"] = self::replace_people_guid($body, $person["url"]);
|
$datarray["body"] = self::replace_people_guid($body, $person["url"]);
|
||||||
|
|
|
@ -233,7 +233,7 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
<h5 class="media-heading">
|
<h5 class="media-heading">
|
||||||
<a href="{{$item.profile_url}}" title="{{$item.linktitle}}" class="wall-item-name-link userinfo"><span class="fakelink">{{$item.name}}</span></a>
|
<a href="{{$item.profile_url}}" title="{{$item.linktitle}}" class="wall-item-name-link userinfo"><span class="fakelink">{{$item.name}}</span></a>
|
||||||
<span class="text-muted">
|
<span class="text-muted">
|
||||||
<small><span title="{{$item.localtime}}" data-toggle="tooltip">{{$item.ago}}</span> {{if $item.location}} — ({{$item.location}}){{/if}}</small>
|
<small><a class="time" href="{{$item.plink.orig}}" title="{{$item.localtime}}" data-toggle="tooltip">{{$item.ago}}</a> {{if $item.location}} — ({{$item.location}}){{/if}}</small>
|
||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue