X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FPost.php;h=d2c0b31e102b436e60adb731fb4ff93bba94d662;hb=ab5a447bc2261522d0f5560f8933dd928a6fc6e3;hp=70142e887f913939b327792e4180f260bb0b55a6;hpb=8d5eb61ea3dd61433cc6f1d2b9000d47340f8342;p=friendica.git diff --git a/src/Object/Post.php b/src/Object/Post.php index 70142e887f..d2c0b31e10 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -33,6 +33,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Post as PostModel; use Friendica\Model\Tag; use Friendica\Model\User; use Friendica\Protocol\Activity; @@ -151,9 +152,10 @@ class Post } $sparkle = ''; $buttons = [ - 'like' => null, - 'dislike' => null, - 'share' => null, + 'like' => null, + 'dislike' => null, + 'share' => null, + 'announce' => null, ]; $dropping = false; $pinned = ''; @@ -175,6 +177,12 @@ class Post : false); $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE; + $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]); + + // On Diaspora only toplevel posts can be reshared + if ($announceable && ($item['network'] == Protocol::DIASPORA) && ($item['gravity'] != GRAVITY_PARENT)) { + $announceable = false; + } $edpost = false; @@ -205,7 +213,7 @@ class Post if (!$origin) { /// @todo This shouldn't be done as query here, but better during the data creation. // it is now done here, since during the RC phase we shouldn't make to intense changes. - $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]); + $parent = PostModel::selectFirst(['origin'], ['id' => $item['parent']]); if (DBA::isResult($parent)) { $origin = $parent['origin']; } @@ -221,15 +229,20 @@ class Post $delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally'); } - $drop = [ - 'dropping' => $dropping, - 'pagedrop' => $item['pagedrop'], - 'select' => DI::l10n()->t('Select'), - 'delete' => $delete, - ]; - - if (!local_user()) { - $drop = false; + $drop = false; + $block = false; + if (local_user()) { + $drop = [ + 'dropping' => $dropping, + 'pagedrop' => $item['pagedrop'], + 'select' => DI::l10n()->t('Select'), + 'delete' => $delete, + ]; + $block = [ + 'blocking' => true, + 'block' => DI::l10n()->t('Block %s', $item['author-name']), + 'author_id' => $item['author-id'], + ]; } $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t("save to folder") : false); @@ -274,8 +287,8 @@ class Post $responses = []; foreach ($response_verbs as $value => $verb) { $responses[$verb] = [ - 'self' => $conv_responses[$verb][$item['uri'] . '-self'] ?? 0, - 'output' => !empty($conv_responses[$verb][$item['uri']]) ? format_like($conv_responses[$verb][$item['uri']], $conv_responses[$verb][$item['uri'] . '-l'], $verb, $item['uri']) : '', + 'self' => $conv_responses[$verb][$item['uri-id']]['self'] ?? 0, + 'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? format_activity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '', ]; } @@ -294,17 +307,15 @@ class Post if ($this->isToplevel()) { if(local_user()) { - $thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]); - if (DBA::isResult($thread)) { - $ignore = [ - 'do' => DI::l10n()->t("ignore thread"), - 'undo' => DI::l10n()->t("unignore thread"), - 'toggle' => DI::l10n()->t("toggle ignore status"), - 'classdo' => $thread['ignored'] ? "hidden" : "", - 'classundo' => $thread['ignored'] ? "" : "hidden", - 'ignored' => DI::l10n()->t('ignored'), - ]; - } + $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user()); + $ignore = [ + '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", + 'ignored' => DI::l10n()->t('ignored'), + ]; if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { if ($origin) { @@ -345,7 +356,11 @@ class Post $buttons['like'] = [DI::l10n()->t("I like this \x28toggle\x29") , DI::l10n()->t("like")]; $buttons['dislike'] = [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")]; if ($shareable) { - $buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')]; + $buttons['share'] = [DI::l10n()->t('Quote share this'), DI::l10n()->t('Quote Share')]; + } + if ($announceable) { + $buttons['announce'] = [DI::l10n()->t('Reshare this'), DI::l10n()->t('Reshare')]; + $buttons['unannounce'] = [DI::l10n()->t('Cancel your Reshare'), DI::l10n()->t('Unshare')]; } } @@ -361,17 +376,12 @@ class Post list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); - $name_e = $profile_name; - $text = strip_tags($body_html); - if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { - $title_e = ucfirst($item['content-warning']); + $title = ucfirst($item['content-warning']); } else { - $title_e = $item['title']; + $title = $item['title']; } - $owner_name_e = $this->getOwnerName(); - if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { $buttons['dislike'] = false; } @@ -412,11 +422,16 @@ class Post } elseif (DI::config()->get('debug', 'show_direction')) { $conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]); if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) { - $title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')]; - $direction = ['direction' => $conversation['direction'], 'title' => $title[$conversation['direction']]]; + $direction_title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')]; + $direction = ['direction' => $conversation['direction'], 'title' => $direction_title[$conversation['direction']]]; } } + $languages = []; + if (!empty($item['language'])) { + $languages = [DI::l10n()->t('Languages'), Item::getLanguageMessage($item)]; + } + $tmp_item = [ 'template' => $this->getTemplate(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), @@ -432,7 +447,7 @@ class Post 'categories' => $categories, 'folders' => $folders, 'body_html' => $body_html, - 'text' => $text, + 'text' => strip_tags($body_html), 'id' => $this->getId(), 'guid' => urlencode($item['guid']), 'isevent' => $isevent, @@ -444,12 +459,12 @@ class Post 'wall' => DI::l10n()->t('Wall-to-Wall'), 'vwall' => DI::l10n()->t('via Wall-To-Wall:'), 'profile_url' => $profile_link, - 'name' => $name_e, + 'name' => $profile_name, 'item_photo_menu_html' => item_photo_menu($item), 'thumb' => DI::baseUrl()->remove($item['author-avatar']), 'osparkle' => $osparkle, 'sparkle' => $sparkle, - 'title' => $title_e, + 'title' => $title, 'localtime' => DateTimeFormat::local($item['created'], 'r'), 'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago, 'app' => $item['app'], @@ -461,7 +476,7 @@ class Post 'owner_self' => $item['author-link'] == Session::get('my_url'), 'owner_url' => $this->getOwnerUrl(), 'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']), - 'owner_name' => $owner_name_e, + 'owner_name' => $this->getOwnerName(), 'plink' => Item::getPlink($item), 'edpost' => $edpost, 'ispinned' => $ispinned, @@ -472,13 +487,15 @@ class Post 'ignore' => $ignore, 'tagger' => $tagger, 'filer' => $filer, + 'language' => $languages, 'drop' => $drop, + 'block' => $block, 'vote' => $buttons, - 'like' => $responses['like']['output'], - 'dislike' => $responses['dislike']['output'], + 'like_html' => $responses['like']['output'], + 'dislike_html' => $responses['dislike']['output'], 'responses' => $responses, 'switchcomment' => DI::l10n()->t('Comment'), - 'reply_label' => DI::l10n()->t('Reply to %s', $name_e), + 'reply_label' => DI::l10n()->t('Reply to %s', $profile_name), 'comment_html' => $comment_html, 'remote_comment' => $remote_comment, 'menu' => DI::l10n()->t('More'), @@ -864,7 +881,7 @@ class Post return ''; } - $item = Item::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]); + $item = PostModel::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]); if (!DBA::isResult($item) || empty($item['author-addr'])) { // Should not happen return ''; @@ -983,7 +1000,7 @@ class Post if ($this->isToplevel()) { if ($conv->getMode() !== 'profile') { - if ($this->getDataValue('wall') && !$this->getDataValue('self')) { + if ($this->getDataValue('wall') && !$this->getDataValue('self') && !empty($a->page_contact)) { // On the network page, I am the owner. On the display page it will be the profile owner. // This will have been stored in $a->page_contact by our calling page. // Put this person as the wall owner of the wall-to-wall notice.