From 637e38e535c0075e0db2cc2d5cf08d938b0e858f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 19 Feb 2020 22:20:26 -0500 Subject: [PATCH] User hide_dislike user setting to hide dislike button and conversation responses --- include/conversation.php | 8 ++++++++ mod/photos.php | 18 ++++++++++++------ src/Object/Post.php | 4 ++++ view/templates/like_noshare.tpl | 4 ++-- view/theme/frio/templates/like_noshare.tpl | 4 ++-- view/theme/quattro/templates/search_item.tpl | 4 +++- view/theme/vier/templates/search_item.tpl | 4 +++- 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index e713994bc6..f29e6d3254 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -587,6 +587,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'announce' => ['title' => DI::l10n()->t('Reshares','title')] ]; + if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { + unset($conv_responses['dislike']); + } + // array with html for each thread (parent+comments) $threads = []; $threadsid = -1; @@ -678,6 +682,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'share' => null, ]; + if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { + unset($likebuttons['dislike']); + } + $body = Item::prepareBody($item, true, $preview); list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); diff --git a/mod/photos.php b/mod/photos.php index 03b78e0e19..9511261553 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1384,7 +1384,7 @@ function photos_content(App $a) $likebuttons = Renderer::replaceMacros($like_tpl, [ '$id' => $link_item['id'], '$likethis' => DI::l10n()->t("I like this \x28toggle\x29"), - '$nolike' => DI::l10n()->t("I don't like this \x28toggle\x29"), + '$dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike') ? '' : DI::l10n()->t("I don't like this \x28toggle\x29"), '$wait' => DI::l10n()->t('Please wait'), '$return_path' => DI::args()->getQueryString(), ]); @@ -1413,10 +1413,17 @@ function photos_content(App $a) } $conv_responses = [ - 'like' => ['title' => DI::l10n()->t('Likes','title')],'dislike' => ['title' => DI::l10n()->t('Dislikes','title')], - 'attendyes' => ['title' => DI::l10n()->t('Attending','title')], 'attendno' => ['title' => DI::l10n()->t('Not attending','title')], 'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')] + 'like' => ['title' => DI::l10n()->t('Likes','title')], + 'dislike' => ['title' => DI::l10n()->t('Dislikes','title')], + 'attendyes' => ['title' => DI::l10n()->t('Attending','title')], + 'attendno' => ['title' => DI::l10n()->t('Not attending','title')], + 'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')] ]; + if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { + unset($conv_responses['dislike']); + } + // display comments if (DBA::isResult($items)) { foreach ($items as $item) { @@ -1515,9 +1522,8 @@ function photos_content(App $a) } } } - $response_verbs = ['like']; - $response_verbs[] = 'dislike'; - $responses = get_responses($conv_responses, $response_verbs, $link_item); + + $responses = get_responses($conv_responses, ['like', 'dislike'], $link_item); $paginate = $pager->renderFull($total); } diff --git a/src/Object/Post.php b/src/Object/Post.php index 5f264c988b..c92c5a32bb 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -373,6 +373,10 @@ class Post $location_e = $location; $owner_name_e = $this->getOwnerName(); + if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { + $buttons['dislike'] = false; + } + // Disable features that aren't available in several networks if ($buttons["dislike"] && !in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) { $buttons["dislike"] = false; diff --git a/view/templates/like_noshare.tpl b/view/templates/like_noshare.tpl index 25e1e09147..3df365e727 100644 --- a/view/templates/like_noshare.tpl +++ b/view/templates/like_noshare.tpl @@ -1,8 +1,8 @@
- {{if $nolike}} - + {{if $dislike}} + {{/if}}
diff --git a/view/theme/frio/templates/like_noshare.tpl b/view/theme/frio/templates/like_noshare.tpl index deb2383f4b..b2a56292c7 100644 --- a/view/theme/frio/templates/like_noshare.tpl +++ b/view/theme/frio/templates/like_noshare.tpl @@ -3,9 +3,9 @@ - {{if $nolike}} + {{if $dislike}} - {{/if}} diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index 75d5ef566f..38ac6cf63d 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -53,8 +53,10 @@ {{$item.star.tagger}} {{/if}} - {{if $item.vote}} + {{if $item.vote.like}} {{$item.vote.like.1}} + {{/if}} + {{if $item.vote.dislike}} {{$item.vote.dislike.1}} {{/if}} diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index bce28962ec..c1bbaf7cf1 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -60,8 +60,10 @@ {{$item.star.tagger}} {{/if}} - {{if $item.vote}} + {{if $item.vote.like}} {{$item.vote.like.1}} + {{/if}} + {{if $item.vote.dislike}} {{$item.vote.dislike.1}} {{/if}}