use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
-use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Psr\Log\LoggerInterface;
$previewing = (($preview) ? ' preview ' : '');
if ($mode === 'network') {
- $items = $this->addChildren($items, false, $order, $uid);
+ $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) {
/*
* The special div is needed for liveUpdate to kick in for this page.
. "'; </script>\r\n";
}
} elseif ($mode === 'profile') {
- $items = $this->addChildren($items, false, $order, $uid);
+ $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) {
$tab = !empty($_GET['tab']) ? trim($_GET['tab']) : 'posts';
}
}
} elseif ($mode === 'notes') {
- $items = $this->addChildren($items, false, $order, local_user());
+ $items = $this->addChildren($items, false, $order, local_user(), $mode);
if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
. "; var netargs = '/?f='; </script>\r\n";
}
} elseif ($mode === 'display') {
- $items = $this->addChildren($items, false, $order, $uid);
+ $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) {
$live_update_div = '<div id="live-display"></div>' . "\r\n"
. "</script>";
}
} elseif ($mode === 'community') {
- $items = $this->addChildren($items, true, $order, $uid);
+ $items = $this->addChildren($items, true, $order, $uid, $mode);
if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
. "'; </script>\r\n";
}
} elseif ($mode === 'contacts') {
- $items = $this->addChildren($items, false, $order, $uid);
+ $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) {
$live_update_div = '<div id="live-contact"></div>' . "\r\n"
$pinned = '';
}
- if (in_array($item['network'], [Protocol::FEED, Protocol::MAIL])) {
- $owner_avatar = $author_avatar = $item['contact-id'];
- $owner_updated = $author_updated = '';
- } else {
- $owner_avatar = $item['owner-id'];
- $owner_updated = $item['owner-updated'];
- $author_avatar = $item['author-id'];
- $author_updated = $item['author-updated'];
- }
-
$tmp_item = [
'template' => $tpl,
'id' => ($preview ? 'P0' : $item['id']),
'name' => $profile_name,
'sparkle' => $sparkle,
'lock' => false,
- 'thumb' => $this->baseURL->remove(Contact::getAvatarUrlForId($author_avatar, Proxy::SIZE_THUMB, $author_updated)),
+ 'thumb' => $this->baseURL->remove($this->item->getAuthorAvatar($item)),
'title' => $title,
'body_html' => $body_html,
'tags' => $tags['tags'],
'indent' => '',
'owner_name' => '',
'owner_url' => '',
- 'owner_photo' => $this->baseURL->remove(Contact::getAvatarUrlForId($owner_avatar, Proxy::SIZE_THUMB, $owner_updated)),
+ 'owner_photo' => $this->baseURL->remove($this->item->getOwnerAvatar($item)),
'plink' => ItemModel::getPlink($item),
'edpost' => false,
'pinned' => $pinned,
{
$this->profiler->startRecording('rendering');
- if ($row['uid'] == 0) {
+ if (!$row['writable']) {
$row['writable'] = in_array($row['network'], Protocol::FEDERATED);
}
* The system will fetch the comments for the local user whenever possible.
* This behaviour is currently needed to allow commenting on Friendica posts.
*
- * @param array $parents Parent items
- *
- * @param $block_authors
- * @param $order
- * @param $uid
+ * @param array $parents Parent items
+ * @param bool $block_authors
+ * @param bool $order
+ * @param int $uid
+ * @param string $mode
* @return array items with parents and comments
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- private function addChildren(array $parents, $block_authors, $order, $uid)
+ private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode)
{
$this->profiler->startRecording('rendering');
if (count($parents) > 1) {
$max_comments = $this->config->get('system', 'max_display_comments', 1000);
}
- $params = ['order' => ['uri-id' => true, 'uid' => true]];
-
$activities = [];
$uriids = [];
$commentcounter = [];
$condition = DBA::mergeConditions($condition,
["`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW)]);
+ $thread_parents = Post::select(['uri-id', 'causer-id'], $condition, ['order' => ['uri-id' => false, 'uid']]);
+
+ $thr_parent = [];
+
+ while ($row = Post::fetch($thread_parents)) {
+ $thr_parent[$row['uri-id']] = $row;
+ }
+ DBA::close($thread_parents);
+
+ $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);
$items = [];
- $thr_parent = [];
while ($row = Post::fetch($thread_items)) {
if (!empty($items[$row['uri-id']]) && ($row['uid'] == 0)) {
continue;
}
+ if (($mode != 'contacts') && !$row['origin']) {
+ $row['featured'] = false;
+ }
+
if ($max_comments > 0) {
if (($row['gravity'] == GRAVITY_COMMENT) && (++$commentcounter[$row['parent-uri-id']] > $max_comments)) {
continue;
}
}
- if (empty($thr_parent[$row['thr-parent-id']])) {
- $thr_parent[$row['thr-parent-id']] = Post::selectFirst(['causer-id'], ['uri-id' => $row['thr-parent-id'], 'uid' => $row['uid']]);
- }
-
- $items[$row['uri-id']] = $this->addRowInformation($row, $activities[$row['uri-id']] ?? [], $thr_parent[$row['thr-parent-id']]);
+ $items[$row['uri-id']] = $this->addRowInformation($row, $activities[$row['uri-id']] ?? [], $thr_parent[$row['thr-parent-id']] ?? []);
}
DBA::close($thread_items);