if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 10)
- ."/?f='; </script>\r\n";
+ . '?f='
+ . (!empty($_GET['no_sharer']) ? '&no_sharer=' . rawurlencode($_GET['no_sharer']) : '')
+ . "'; </script>\r\n";
}
} elseif ($mode === 'contacts') {
$items = conversation_add_children($items, false, $order, $uid);
$profile_owner = 0;
if (!$update) {
- $live_update_div = '<div id="live-contacts"></div>' . "\r\n"
- . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
+ $live_update_div = '<div id="live-contact"></div>' . "\r\n"
+ . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 8)
."/?f='; </script>\r\n";
}
} elseif ($mode === 'search') {
$writable = false;
}
- if (in_array($mode, ['network-new', 'search', 'contact-posts'])) {
+ if (in_array($mode, ['filed', 'search', 'contact-posts'])) {
/*
* "New Item View" on network page or search page results
$location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: '');
localize_item($item);
- if ($mode === 'network-new') {
+ if ($mode === 'filed') {
$dropping = true;
} else {
$dropping = false;
];
$likebuttons = [
- 'like' => null,
- 'dislike' => null,
- 'share' => null,
+ 'like' => null,
+ 'dislike' => null,
+ 'share' => null,
+ 'announce' => null,
];
if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
'template' => $tpl,
'id' => ($preview ? 'P0' : $item['id']),
'guid' => ($preview ? 'Q0' : $item['guid']),
+ 'commented' => $item['commented'],
+ 'received' => $item['received'],
+ 'created_date' => $item['created'],
+ 'uriid' => $item['uri-id'],
'network' => $item['network'],
'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
'$live_update' => $live_update_div,
'$remove' => DI::l10n()->t('remove'),
'$mode' => $mode,
+ '$update' => $update,
'$user' => $a->user,
'$threads' => $threads,
'$dropping' => ($page_dropping ? DI::l10n()->t('Delete Selected Items') : False),
*
* @param mixed $thread_items Database statement with thread posts
* @param boolean $pinned Is the item pinned?
+ * @param integer $causer Contact ID of the resharer
*
* @return array items with parents and comments
*/
-function conversation_fetch_comments($thread_items, $pinned) {
+function conversation_fetch_comments($thread_items, $pinned, $causer) {
$comments = [];
while ($row = Item::fetch($thread_items)) {
+ if (!empty($causer)) {
+ if (($row['gravity'] == GRAVITY_PARENT)) {
+ $row['post-type'] = Item::PT_ANNOUNCEMENT;
+ $row['causer-id'] = $causer;
+ $contact = Contact::getById($causer, ['url', 'name', 'thumb']);
+ $row['causer-link'] = $contact['url'];
+ $row['causer-avatar'] = $contact['thumb'];
+ $row['causer-name'] = $contact['name'];
+ } elseif (($row['gravity'] == GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
+ ($row['author-id'] == $causer)) {
+ continue;
+ }
+ }
+
$name = $row['causer-contact-type'] == Contact::TYPE_RELAY ? $row['causer-link'] : $row['causer-name'];
switch ($row['post-type']) {
$row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
break;
case Item::PT_ANNOUNCEMENT:
- if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer') ) {
+ if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')) {
+ $row['owner-id'] = $row['causer-id'];
$row['owner-link'] = $row['causer-link'];
$row['owner-avatar'] = $row['causer-avatar'];
$row['owner-name'] = $row['causer-name'];
$items = [];
foreach ($parents AS $parent) {
- $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);
+ if (!empty($parent['thr-parent-id']) && !empty($parent['gravity']) && ($parent['gravity'] == GRAVITY_ACTIVITY)) {
+ $condition = ["`item`.`parent-uri-id` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
+ $parent['thr-parent-id'], $uid, Verb::getID(Activity::FOLLOW)];
+ $causer = $parent['author-id'] ?? 0;
+ } else {
+ $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
+ $parent['uri'], $uid, Verb::getID(Activity::FOLLOW)];
+ $causer = 0;
+ }
+ $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params, $causer);
}
foreach ($items as $index => $item) {
/**
* Fetch conversation items
*
- * @param array $parent
- * @param array $items
- * @param array $condition
- * @param boolean $block_authors
- * @param array $params
+ * @param array $parent Parent Item array
+ * @param array $items Item array
+ * @param array $condition SQL condition
+ * @param boolean $block_authors Don't show posts from contacts that are hidden (used on the community page)
+ * @param array $params SQL parameters
+ * @param integer $causer Contact ID of the resharer
* @return array
*/
-function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
+function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params, int $causer) {
if ($block_authors) {
$condition[0] .= " AND NOT `author`.`hidden`";
}
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity', 'post-type']), $condition, $params);
- $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
+ $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false, $causer);
if (count($comments) != 0) {
$items = array_merge($items, $comments);
DI::l10n()->t('Ignore') => $ignore_link
];
+ if (!empty($item['language'])) {
+ $menu[DI::l10n()->t('Languages')] = 'javascript:alert(\'' . Item::getLanguageMessage($item) . '\');';
+ }
+
if ($network == Protocol::DFRN) {
$menu[DI::l10n()->t("Poke")] = $poke_link;
}
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
in_array($item['network'], Protocol::FEDERATED)) {
- $menu[DI::l10n()->t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
+ $menu[DI::l10n()->t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']) . '&auto=1';
}
} else {
$menu = [DI::l10n()->t('View Profile') => $item['author-link']];
continue;
}
+ // Skip when the causer of the parent is the same than the author of the announce
+ if (($verb == Activity::ANNOUNCE) && Item::exists(['uri' => $item['thr-parent'],
+ 'uid' => $item['uid'], 'causer-id' => $item['author-id'], 'gravity' => GRAVITY_PARENT])) {
+ continue;
+ }
+
if (!isset($conv_responses[$mode][$item['thr-parent']])) {
$conv_responses[$mode][$item['thr-parent']] = 1;
} else {