From 355284841aaada87b6600300b8fcd42bab2a78e6 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 26 Aug 2020 12:33:17 +0000 Subject: [PATCH 1/2] Optionally display the resharer as icon --- include/conversation.php | 7 +++++++ src/Module/Settings/Display.php | 4 ++++ static/settings.config.php | 4 ++++ view/templates/settings/display.tpl | 1 + view/theme/frio/templates/settings/display.tpl | 1 + 5 files changed, 17 insertions(+) diff --git a/include/conversation.php b/include/conversation.php index 7ff4de2ea..c668e53d9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -711,6 +711,7 @@ function conversation_fetch_comments($thread_items, $pinned) { $parentlines = []; $lineno = 0; $direction = []; + $actor = []; $received = ''; while ($row = Item::fetch($thread_items)) { @@ -718,6 +719,7 @@ function conversation_fetch_comments($thread_items, $pinned) { && ($row['thr-parent'] == $row['parent-uri']) && ($row['received'] > $received) && Contact::isSharing($row['author-id'], $row['uid'])) { $direction = ['direction' => 3, 'title' => DI::l10n()->t('%s reshared this.', $row['author-name'])]; + $actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']]; $received = $row['received']; } @@ -748,6 +750,11 @@ function conversation_fetch_comments($thread_items, $pinned) { if (!empty($direction)) { foreach ($parentlines as $line) { $comments[$line]['direction'] = $direction; + if (!empty($actor) && DI::pConfig()->get(local_user(), 'system', 'display_resharer') ) { + $comments[$line]['owner-link'] = $actor['link']; + $comments[$line]['owner-avatar'] = $actor['avatar']; + $comments[$line]['owner-name'] = $actor['name']; + } } } return $comments; diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index bde049718..443385394 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -52,6 +52,7 @@ class Display extends BaseSettings $no_auto_update = !empty($_POST['no_auto_update']) ? intval($_POST['no_auto_update']) : 0; $no_smart_threading = !empty($_POST['no_smart_threading']) ? intval($_POST['no_smart_threading']) : 0; $hide_dislike = !empty($_POST['hide_dislike']) ? intval($_POST['hide_dislike']) : 0; + $display_resharer = !empty($_POST['display_resharer']) ? intval($_POST['display_resharer']) : 0; $browser_update = !empty($_POST['browser_update']) ? intval($_POST['browser_update']) : 0; if ($browser_update != -1) { $browser_update = $browser_update * 1000; @@ -85,6 +86,7 @@ class Display extends BaseSettings DI::pConfig()->set(local_user(), 'system', 'infinite_scroll' , $infinite_scroll); DI::pConfig()->set(local_user(), 'system', 'no_smart_threading' , $no_smart_threading); DI::pConfig()->set(local_user(), 'system', 'hide_dislike' , $hide_dislike); + DI::pConfig()->set(local_user(), 'system', 'display_resharer' , $display_resharer); DI::pConfig()->set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week); if (in_array($theme, Theme::getAllowedList())) { @@ -166,6 +168,7 @@ class Display extends BaseSettings $infinite_scroll = DI::pConfig()->get(local_user(), 'system', 'infinite_scroll', 0); $no_smart_threading = DI::pConfig()->get(local_user(), 'system', 'no_smart_threading', 0); $hide_dislike = DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0); + $display_resharer = DI::pConfig()->get(local_user(), 'system', 'display_resharer', 0); $first_day_of_week = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0); $weekdays = [0 => DI::l10n()->t("Sunday"), 1 => DI::l10n()->t("Monday")]; @@ -202,6 +205,7 @@ class Display extends BaseSettings '$infinite_scroll' => ['infinite_scroll' , DI::l10n()->t('Infinite scroll'), $infinite_scroll, DI::l10n()->t('Automatic fetch new items when reaching the page end.')], '$no_smart_threading' => ['no_smart_threading' , DI::l10n()->t('Disable Smart Threading'), $no_smart_threading, DI::l10n()->t('Disable the automatic suppression of extraneous thread indentation.')], '$hide_dislike' => ['hide_dislike' , DI::l10n()->t('Hide the Dislike feature'), $hide_dislike, DI::l10n()->t('Hides the Dislike button and dislike reactions on posts and comments.')], + '$display_resharer' => ['display_resharer' , DI::l10n()->t('Display the resharer'), $display_resharer, DI::l10n()->t('Display the first resharer as icon and text on a reshared item.')], '$first_day_of_week' => ['first_day_of_week', DI::l10n()->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false], ]); diff --git a/static/settings.config.php b/static/settings.config.php index 19f47d2b8..9c4e739f0 100644 --- a/static/settings.config.php +++ b/static/settings.config.php @@ -150,6 +150,10 @@ return [ // optimize_tables (Boolean) // Periodically (once an hour) run an "optimize table" command for cache tables 'optimize_tables' => false, + + // display_resharer (Boolean) + // Display the first resharer as icon and text on a reshared item. + 'display_resharer' => false, ], // Used in the admin settings to lock certain features diff --git a/view/templates/settings/display.tpl b/view/templates/settings/display.tpl index 15247d874..3700c4f54 100644 --- a/view/templates/settings/display.tpl +++ b/view/templates/settings/display.tpl @@ -18,6 +18,7 @@ {{include file="field_checkbox.tpl" field=$infinite_scroll}} {{include file="field_checkbox.tpl" field=$no_smart_threading}} {{include file="field_checkbox.tpl" field=$hide_dislike}} + {{include file="field_checkbox.tpl" field=$display_resharer}}

{{$calendar_title}}

{{include file="field_select.tpl" field=$first_day_of_week}} diff --git a/view/theme/frio/templates/settings/display.tpl b/view/theme/frio/templates/settings/display.tpl index defb0903b..4ba751836 100644 --- a/view/theme/frio/templates/settings/display.tpl +++ b/view/theme/frio/templates/settings/display.tpl @@ -65,6 +65,7 @@ {{include file="field_checkbox.tpl" field=$infinite_scroll}} {{include file="field_checkbox.tpl" field=$no_smart_threading}} {{include file="field_checkbox.tpl" field=$hide_dislike}} + {{include file="field_checkbox.tpl" field=$display_resharer}}