X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FConversation.php;h=c5e854b1d9ece6a02f55ab98e9238aec0ef4022b;hb=21f172c585aff8c606774a05fde1548ddff1667d;hp=46a906b13829ca1448e1e2d6736b7ad67579be6a;hpb=7a39be8270c1ce56c7a2df078bfbfd310601c569;p=friendica.git diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index 46a906b138..c5e854b1d9 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -1,6 +1,6 @@ l10n->t('and %d other people', $total - $this->config->get('system', 'max_likers')); } - $spanatts = "class=\"fakelink\" onclick=\"openClose('{$verb}list-$id');\""; + $spanatts = "class=\"btn btn-link fakelink\" onclick=\"openClose('{$verb}list-$id');\""; $explikers = ''; switch ($verb) { case 'like': - $phrase = $this->l10n->t('%2$d people like this', $spanatts, $total); + $phrase = $this->l10n->t(' like this', $spanatts, $total); $explikers = $this->l10n->t('%s like this.', $likers); break; case 'dislike': - $phrase = $this->l10n->t('%2$d people don\'t like this', $spanatts, $total); + $phrase = $this->l10n->t(' don\'t like this', $spanatts, $total); $explikers = $this->l10n->t('%s don\'t like this.', $likers); break; case 'attendyes': - $phrase = $this->l10n->t('%2$d people attend', $spanatts, $total); + $phrase = $this->l10n->t(' attend', $spanatts, $total); $explikers = $this->l10n->t('%s attend.', $likers); break; case 'attendno': - $phrase = $this->l10n->t('%2$d people don\'t attend', $spanatts, $total); + $phrase = $this->l10n->t(' don\'t attend', $spanatts, $total); $explikers = $this->l10n->t('%s don\'t attend.', $likers); break; case 'attendmaybe': - $phrase = $this->l10n->t('%2$d people attend maybe', $spanatts, $total); + $phrase = $this->l10n->t(' attend maybe', $spanatts, $total); $explikers = $this->l10n->t('%s attend maybe.', $likers); break; case 'announce': - $phrase = $this->l10n->t('%2$d people reshared this', $spanatts, $total); + $phrase = $this->l10n->t(' reshared this', $spanatts, $total); $explikers = $this->l10n->t('%s reshared this.', $likers); break; } @@ -444,7 +454,7 @@ class Conversation $previewing = (($preview) ? ' preview ' : ''); - if ($mode === 'network') { + if ($mode === self::MODE_NETWORK) { $items = $this->addChildren($items, false, $order, $uid, $mode); if (!$update) { /* @@ -470,7 +480,7 @@ class Conversation . "'; \r\n"; } - } elseif ($mode === 'profile') { + } elseif ($mode === self::MODE_PROFILE) { $items = $this->addChildren($items, false, $order, $uid, $mode); if (!$update) { @@ -487,7 +497,7 @@ class Conversation . "; var netargs = '?f='; \r\n"; } } - } elseif ($mode === 'notes') { + } elseif ($mode === self::MODE_NOTES) { $items = $this->addChildren($items, false, $order, $this->session->getLocalUserId(), $mode); if (!$update) { @@ -495,7 +505,7 @@ class Conversation . "\r\n"; } - } elseif ($mode === 'display') { + } elseif ($mode === self::MODE_DISPLAY) { $items = $this->addChildren($items, false, $order, $uid, $mode); if (!$update) { @@ -503,7 +513,7 @@ class Conversation . ""; } - } elseif ($mode === 'community') { + } elseif ($mode === self::MODE_COMMUNITY) { $items = $this->addChildren($items, true, $order, $uid, $mode); if (!$update) { @@ -514,7 +524,7 @@ class Conversation . (!empty($_GET['accounttype']) ? '&accounttype=' . rawurlencode($_GET['accounttype']) : '') . "'; \r\n"; } - } elseif ($mode === 'contacts') { + } elseif ($mode === self::MODE_CONTACTS) { $items = $this->addChildren($items, false, $order, $uid, $mode); if (!$update) { @@ -522,11 +532,11 @@ class Conversation . "\r\n"; } - } elseif ($mode === 'search') { + } elseif ($mode === self::MODE_SEARCH) { $live_update_div = '' . "\r\n"; } - $page_dropping = $this->session->getLocalUserId() && $this->session->getLocalUserId() == $uid; + $page_dropping = $this->session->getLocalUserId() && $this->session->getLocalUserId() == $uid && $mode != self::MODE_SEARCH; if (!$update) { $_SESSION['return_path'] = $this->args->getQueryString(); @@ -558,7 +568,7 @@ class Conversation $formSecurityToken = BaseModule::getFormSecurityToken('contact_action'); if (!empty($items)) { - if (in_array($mode, ['community', 'contacts', 'profile'])) { + if (in_array($mode, [self::MODE_COMMUNITY, self::MODE_CONTACTS, self::MODE_PROFILE])) { $writable = true; } else { $writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED); @@ -568,7 +578,7 @@ class Conversation $writable = false; } - if (in_array($mode, ['filed', 'search', 'contact-posts'])) { + if (in_array($mode, [self::MODE_FILED, self::MODE_SEARCH, self::MODE_CONTACT_POSTS])) { /* * "New Item View" on network page or search page results @@ -621,7 +631,7 @@ class Conversation $location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: ''); $this->item->localize($item); - if ($mode === 'filed') { + if ($mode === self::MODE_FILED) { $dropping = true; } else { $dropping = false; @@ -794,10 +804,7 @@ class Conversation return []; } - $blocked = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked'); - if (!empty($blocked)) { - $str_blocked = str_replace(["\n", "\r"], ",", $blocked); - } + $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked') ?? ''); if (empty($str_blocked)) { return []; } @@ -973,7 +980,12 @@ class Conversation } $condition = DBA::mergeConditions($condition, - ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW)]); + ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]); + + $condition = DBA::mergeConditions($condition, + ["`visible` AND NOT `deleted` AND NOT `author-blocked` AND NOT `owner-blocked` + AND ((NOT `contact-pending` AND (`contact-rel` IN (?, ?))) OR `self` OR `contact-uid` = ?)", + Contact::SHARING, Contact::FRIEND, 0]); $thread_parents = Post::select(['uri-id', 'causer-id'], $condition, ['order' => ['uri-id' => false, 'uid']]); @@ -986,16 +998,18 @@ class Conversation $params = ['order' => ['uri-id' => true, 'uid' => true]]; - $thread_items = Post::selectForUser($uid, array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params); + $thread_items = Post::select(array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params); - $items = []; + $items = []; + $quote_uri_ids = []; + $authors = []; while ($row = Post::fetch($thread_items)) { if (!empty($items[$row['uri-id']]) && ($row['uid'] == 0)) { continue; } - if (($mode != 'contacts') && !$row['origin']) { + if (($mode != self::MODE_CONTACTS) && !$row['origin']) { $row['featured'] = false; } @@ -1008,11 +1022,80 @@ class Conversation } } + $authors[] = $row['author-id']; + $authors[] = $row['owner-id']; + + if (in_array($row['gravity'], [ItemModel::GRAVITY_PARENT, ItemModel::GRAVITY_COMMENT])) { + $quote_uri_ids[$row['uri-id']] = [ + 'uri-id' => $row['uri-id'], + 'uri' => $row['uri'], + 'parent-uri-id' => $row['parent-uri-id'], + 'parent-uri' => $row['parent-uri'], + ]; + } + $items[$row['uri-id']] = $this->addRowInformation($row, $activities[$row['uri-id']] ?? [], $thr_parent[$row['thr-parent-id']] ?? []); } DBA::close($thread_items); + $quotes = Post::select(array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), ['quote-uri-id' => array_column($quote_uri_ids, 'uri-id'), 'body' => '', 'uid' => 0]); + while ($quote = Post::fetch($quotes)) { + $row = $quote; + + $row['uid'] = $uid; + $row['verb'] = $row['body'] = $row['raw-body'] = Activity::ANNOUNCE; + $row['gravity'] = ItemModel::GRAVITY_ACTIVITY; + $row['object-type'] = Activity\ObjectType::NOTE; + $row['parent-uri'] = $quote_uri_ids[$quote['quote-uri-id']]['parent-uri']; + $row['parent-uri-id'] = $quote_uri_ids[$quote['quote-uri-id']]['parent-uri-id']; + $row['thr-parent'] = $quote_uri_ids[$quote['quote-uri-id']]['uri']; + $row['thr-parent-id'] = $quote_uri_ids[$quote['quote-uri-id']]['uri-id']; + + $authors[] = $row['author-id']; + $authors[] = $row['owner-id']; + + $items[$row['uri-id']] = $this->addRowInformation($row, [], []); + } + DBA::close($quotes); + + $authors = array_unique($authors); + + $blocks = []; + $ignores = []; + $collapses = []; + if (!empty($authors)) { + $usercontacts = DBA::select('user-contact', ['cid', 'blocked', 'ignored', 'collapsed'], ['uid' => $uid, 'cid' => $authors]); + while ($usercontact = DBA::fetch($usercontacts)) { + if ($usercontact['blocked']) { + $blocks[] = $usercontact['cid']; + } + if ($usercontact['ignored']) { + $ignores[] = $usercontact['cid']; + } + if ($usercontact['collapsed']) { + $collapses[] = $usercontact['cid']; + } + } + DBA::close($usercontacts); + } + + foreach ($items as $key => $row) { + $always_display = in_array($mode, [self::MODE_CONTACTS, self::MODE_CONTACT_POSTS]); + + $items[$key]['user-blocked-author'] = !$always_display && in_array($row['author-id'], $blocks); + $items[$key]['user-ignored-author'] = !$always_display && in_array($row['author-id'], $ignores); + $items[$key]['user-blocked-owner'] = !$always_display && in_array($row['owner-id'], $blocks); + $items[$key]['user-ignored-owner'] = !$always_display && in_array($row['owner-id'], $ignores); + $items[$key]['user-collapsed-author'] = !$always_display && in_array($row['author-id'], $collapses); + $items[$key]['user-collapsed-owner'] = !$always_display && in_array($row['owner-id'], $collapses); + + if (in_array($mode, [self::MODE_COMMUNITY, self::MODE_NETWORK]) && + (in_array($row['author-id'], $blocks) || in_array($row['owner-id'], $blocks) || in_array($row['author-id'], $ignores) || in_array($row['owner-id'], $ignores))) { + unset($items[$key]); + } + } + $items = $this->convSort($items, $order); $this->profiler->stopRecording();