use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
-use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Profile;
-use Friendica\Model\Term;
+use Friendica\Model\Tag;
+use Friendica\Model\Verb;
use Friendica\Object\Post;
use Friendica\Object\Thread;
use Friendica\Protocol\Activity;
if (!empty($item['verb'])) {
$activity = DI::activity();
+ $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
+
if (stristr($item['verb'], Activity::POKE)) {
- $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
+ $verb = urldecode(substr($item['verb'], strpos($item['verb'],'#') + 1));
if (!$verb) {
return;
}
- if ($item['object-type']=="" || $item['object-type']!== Activity\ObjectType::PERSON) {
+ if ($item['object-type'] == "" || $item['object-type'] !== Activity\ObjectType::PERSON) {
return;
}
$Aname = $item['author-name'];
$Alink = $item['author-link'];
- $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
-
- $obj = XML::parseString($xmlhead.$item['object']);
+ $obj = XML::parseString($xmlhead . $item['object']);
$Bname = $obj->title;
$Blink = $obj->id;
$txt = DI::l10n()->t('%1$s poked %2$s');
// now translate the verb
- $poked_t = trim(sprintf($txt, "", ""));
+ $poked_t = trim(sprintf($txt, '', ''));
$txt = str_replace($poked_t, DI::l10n()->t($verb), $txt);
// then do the sprintf on the translation string
- $item['body'] = sprintf($txt, $A, $B). "\n\n\n" . $Bphoto;
+ $item['body'] = sprintf($txt, $A, $B) . "\n\n\n" . $Bphoto;
}
- if ($activity->match($item['verb'], Activity::TAG)) {
+ if ($activity->match($item['verb'], Activity::TAG)) {
$fields = ['author-id', 'author-link', 'author-name', 'author-network',
'verb', 'object-type', 'resource-id', 'body', 'plink'];
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
}
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
- $parsedobj = XML::parseString($xmlhead.$item['object']);
+ $parsedobj = XML::parseString($xmlhead . $item['object']);
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
$item['body'] = DI::l10n()->t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
. "<script> var profile_uid = " . $_SESSION['uid']
. "; var netargs = '" . substr(DI::args()->getCommand(), 8)
. '?f='
- . (!empty($_GET['cid']) ? '&cid=' . rawurlencode($_GET['cid']) : '')
- . (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
- . (!empty($_GET['star']) ? '&star=' . rawurlencode($_GET['star']) : '')
- . (!empty($_GET['order']) ? '&order=' . rawurlencode($_GET['order']) : '')
- . (!empty($_GET['bmark']) ? '&bmark=' . rawurlencode($_GET['bmark']) : '')
- . (!empty($_GET['liked']) ? '&liked=' . rawurlencode($_GET['liked']) : '')
- . (!empty($_GET['conv']) ? '&conv=' . rawurlencode($_GET['conv']) : '')
- . (!empty($_GET['nets']) ? '&nets=' . rawurlencode($_GET['nets']) : '')
- . (!empty($_GET['cmin']) ? '&cmin=' . rawurlencode($_GET['cmin']) : '')
- . (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
- . (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
+ . (!empty($_GET['contactid']) ? '&contactid=' . rawurlencode($_GET['contactid']) : '')
+ . (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
+ . (!empty($_GET['star']) ? '&star=' . rawurlencode($_GET['star']) : '')
+ . (!empty($_GET['order']) ? '&order=' . rawurlencode($_GET['order']) : '')
+ . (!empty($_GET['bmark']) ? '&bmark=' . rawurlencode($_GET['bmark']) : '')
+ . (!empty($_GET['liked']) ? '&liked=' . rawurlencode($_GET['liked']) : '')
+ . (!empty($_GET['conv']) ? '&conv=' . rawurlencode($_GET['conv']) : '')
+ . (!empty($_GET['nets']) ? '&nets=' . rawurlencode($_GET['nets']) : '')
+ . (!empty($_GET['cmin']) ? '&cmin=' . rawurlencode($_GET['cmin']) : '')
+ . (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
+ . (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
. "'; </script>\r\n";
}
$profile_name = $item['author-link'];
}
- $tags = Term::populateTagsFromItem($item);
+ $tags = Tag::populateFromItem($item);
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$item['pagedrop'] = $page_dropping;
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$item_object = new Post($item);
$conv->addParent($item_object);
}
$items = [];
foreach ($parents AS $parent) {
- $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ",
- $parent['uri'], $uid];
- if ($block_authors) {
- $condition[0] .= "AND NOT `author`.`hidden`";
- }
-
- $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
-
- $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
-
- if (count($comments) != 0) {
- $items = array_merge($items, $comments);
- }
+ $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
+ $parent['uri'], $uid, Verb::getID(Activity::FOLLOW)];
+ $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params);
}
foreach ($items as $index => $item) {
return $items;
}
+/**
+ * Fetch conversation items
+ *
+ * @param array $parent
+ * @param array $items
+ * @param array $condition
+ * @param boolean $block_authors
+ * @param array $params
+ * @return array
+ */
+function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
+ if ($block_authors) {
+ $condition[0] .= " AND NOT `author`.`hidden`";
+ }
+
+ $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
+
+ $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
+
+ if (count($comments) != 0) {
+ $items = array_merge($items, $comments);
+ }
+ return $items;
+}
+
function item_photo_menu($item) {
$sub_link = '';
$poke_link = '';
$block_link = '';
$ignore_link = '';
- if (local_user() && local_user() == $item['uid'] && $item['parent'] == $item['id'] && !$item['self']) {
+ if (local_user() && local_user() == $item['uid'] && $item['gravity'] == GRAVITY_PARENT && !$item['self']) {
$sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
}
if (!empty($pcid)) {
$contact_url = 'contact/' . $pcid;
- $posts_link = 'contact/' . $pcid . '/posts';
- $block_link = 'contact/' . $pcid . '/block';
- $ignore_link = 'contact/' . $pcid . '/ignore';
+ $posts_link = $contact_url . '/posts';
+ $block_link = $contact_url . '/block';
+ $ignore_link = $contact_url . '/ignore';
}
if ($cid && !$item['self']) {
- $poke_link = 'poke?c=' . $cid;
$contact_url = 'contact/' . $cid;
- $posts_link = 'contact/' . $cid . '/posts';
+ $poke_link = $contact_url . '/poke';
+ $posts_link = $contact_url . '/posts';
if (in_array($network, [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
$pm_url = 'message/new/' . $cid;
return;
}
- if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
+ if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['gravity'] != GRAVITY_PARENT)) {
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$url = Contact::magicLinkByContact($author);
{
$children = [];
foreach ($item_list as $i => $item) {
- if ($item['id'] != $item['parent']) {
+ if ($item['gravity'] != GRAVITY_PARENT) {
if ($recursive) {
// Fallback to parent-uri if thr-parent is not set
$thr_parent = $item['thr-parent'];
// Extract the top level items
foreach ($item_array as $item) {
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$parents[] = $item;
}
}