Merge pull request #3722 from annando/diaspora-plink
The plink in Diaspora posts now links to the correct place
This commit is contained in:
commit
7360945d8a
2 changed files with 24 additions and 10 deletions
|
@ -1183,7 +1183,7 @@ class Diaspora {
|
|||
* @return array the item record
|
||||
*/
|
||||
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`,
|
||||
`owner-name`, `owner-link`, `owner-avatar`
|
||||
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
|
||||
|
@ -1266,27 +1266,39 @@ class Diaspora {
|
|||
*
|
||||
* @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));
|
||||
|
||||
// Fallback
|
||||
if (!$r)
|
||||
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$guid;
|
||||
if (!dbm::is_result($r)) {
|
||||
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
|
||||
// So we try another way as well.
|
||||
$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"];
|
||||
}
|
||||
|
||||
if ($r[0]["network"] == NETWORK_DFRN)
|
||||
return(str_replace("/profile/".$r[0]["nick"]."/", "/display/".$guid, $r[0]["url"]."/"));
|
||||
if ($r[0]["network"] == NETWORK_DFRN) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ($parent_guid != '') {
|
||||
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$parent_guid."#".$guid;
|
||||
} else {
|
||||
return "https://".substr($addr,strpos($addr,"@")+1)."/posts/".$guid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Processes an account deletion
|
||||
|
@ -1459,6 +1471,8 @@ class Diaspora {
|
|||
|
||||
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
||||
|
||||
$datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
|
||||
|
||||
$body = diaspora2bb($text);
|
||||
|
||||
$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">
|
||||
<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">
|
||||
<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>
|
||||
</h5>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue