<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
$pinned = '';
$pin = false;
$star = false;
- $ignore = false;
+ $ignore_thread = false;
$ispinned = 'unpinned';
$isstarred = 'unstarred';
$indent = '';
if (DI::userSession()->getLocalUserId()) {
if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) {
if ($item['event-id'] != 0) {
- $edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
+ $edpost = ['calendar/event/edit/' . $item['event-id'], DI::l10n()->t('Edit')];
} else {
- $edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')];
+ $edpost = [sprintf('post/%s/edit', $item['id']), DI::l10n()->t('Edit')];
}
}
$dropping = in_array($item['uid'], [0, DI::userSession()->getLocalUserId()]);
// Showing the one or the other text, depending upon if we can only hide it or really delete it.
$delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
- $drop = false;
- $block = false;
+ $drop = false;
+ $block = false;
+ $ignore = false;
if (DI::userSession()->getLocalUserId()) {
$drop = [
'dropping' => $dropping,
if (!$item['self'] && DI::userSession()->getLocalUserId()) {
$block = [
- 'blocking' => true,
- 'block' => DI::l10n()->t('Block %s', $item['author-name']),
- 'author_id' => $item['author-id'],
+ 'blocking' => true,
+ 'block' => DI::l10n()->t('Block %s', $item['author-name']),
+ 'author_id' => $item['author-id'],
+ ];
+ $ignore = [
+ 'ignoring' => true,
+ 'ignore' => DI::l10n()->t('Ignore %s', $item['author-name']),
+ 'author_id' => $item['author-id'],
];
}
$profile_link = $item['author-link'];
}
- if (strpos($profile_link, 'redir/') === 0) {
+ if (strpos($profile_link, 'contact/redir/') === 0) {
$sparkle = ' sparkle';
}
if ($this->isToplevel()) {
if (DI::userSession()->getLocalUserId()) {
- $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
- if ($item['mention'] || $ignored) {
- $ignore = [
+ $ignored_thread = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
+ if ($item['mention'] || $ignored_thread) {
+ $ignore_thread = [
'do' => DI::l10n()->t('Ignore thread'),
'undo' => DI::l10n()->t('Unignore thread'),
'toggle' => DI::l10n()->t('Toggle ignore status'),
- 'classdo' => $ignored ? 'hidden' : '',
- 'classundo' => $ignored ? '' : 'hidden',
+ 'classdo' => $ignored_thread ? 'hidden' : '',
+ 'classundo' => $ignored_thread ? '' : 'hidden',
'ignored' => DI::l10n()->t('Ignored'),
];
}
'pinned' => $pinned,
'isstarred' => $isstarred,
'star' => $star,
- 'ignore' => $ignore,
+ 'ignore' => $ignore_thread,
'tagger' => $tagger,
'filer' => $filer,
'language' => $languages,
'drop' => $drop,
'block' => $block,
+ 'ignore_author' => $ignore,
'vote' => $buttons,
'like_html' => $responses['like']['output'],
'dislike_html' => $responses['dislike']['output'],
}
}
+ // Copy values/set defaults
$result['total_comments_num'] = $this->isToplevel() ? $total_children : 0;
-
- $result['private'] = $item['private'];
- $result['toplevel'] = ($this->isToplevel() ? 'toplevel_item' : '');
-
- if ($this->isThreaded()) {
- $result['flatten'] = false;
- $result['threaded'] = true;
- } else {
- $result['flatten'] = true;
- $result['threaded'] = false;
- }
+ $result['private'] = $item['private'];
+ $result['toplevel'] = ($this->isToplevel() ? 'toplevel_item' : '');
+ $result['flatten'] = !$this->isThreaded();
+ $result['threaded'] = $this->isThreaded();
return $result;
}
}
/**
- * Add a child item
+ * Add a child post
*
- * @param Post $item The child item to add
+ * @param Post $item The child post to add
*
- * @return mixed
+ * @return Post|bool Last Post object or bool on any error
* @throws \Exception
*/
public function addChild(Post $item)
{
- $item_id = $item->getId();
- if (!$item_id) {
- Logger::info('[ERROR] Post::addChild : Item has no ID!!');
+ if (!$item->getId()) {
+ Logger::error('Post object has no id', ['post' => $item]);
return false;
} elseif ($this->getChild($item->getId())) {
- Logger::info('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').');
+ Logger::warning('Post object already exists', ['post' => $item]);
return false;
}
- $activity = DI::activity();
-
/*
* Only add what will be displayed
*/
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
+ Logger::warning('Post object does not belong to local user', ['post' => $item, 'local_user' => DI::userSession()->getLocalUserId()]);
return false;
- } elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
- $activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
+ } elseif (DI::activity()->match($item->getDataValue('verb'), Activity::LIKE) ||
+ DI::activity()->match($item->getDataValue('verb'), Activity::DISLIKE)) {
+ Logger::warning('Post objects is a like/dislike', ['post' => $item]);
return false;
}
* Get a child by its ID
*
* @param integer $id The child id
- * @return mixed
+ * @return Thread|null Thread or NULL if not found
*/
public function getChild(int $id)
{
* Set conversation thread
*
* @param Thread|null $thread
+ *
* @return void
*/
public function setThread(Thread $thread = null)
* Get a data value
*
* @param string $name key
+ *
* @return mixed value on success, false on failure
*/
public function getDataValue(string $name)
}
/**
- * Set template
+ * Set template by name
*
* @param string $name Template name
- * @return bool If template was set
+ *
+ * @return void
* @throws InvalidArgumentException
*/
- private function setTemplate(string $name): bool
+ private function setTemplate(string $name)
{
if (empty($this->available_templates[$name])) {
// Throw exception
}
$this->template = $this->available_templates[$name];
-
- return true;
}
/**
* Get the comment box
*
* @param string $indent Indent value
+ *
* @return mixed The comment box string (empty if no comment box), false on failure
* @throws \Exception
* @todo return false is nowhere in this method?
$this->wall_to_wall = true;
$owner = [
- 'uid' => 0,
- 'id' => $this->getDataValue('owner-id'),
+ 'uid' => 0,
+ 'id' => $this->getDataValue('owner-id'),
'network' => $this->getDataValue('owner-network'),
- 'url' => $this->getDataValue('owner-link'),
+ 'url' => $this->getDataValue('owner-link'),
];
$this->owner_url = Contact::magicLinkByContact($owner);
}