From cf5beafec01263b25e5fa3d37700635dba456948 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 2 Oct 2023 21:34:49 -0400 Subject: [PATCH] Move self key to $profile tamplate variable in hovercard.tpl template - Simplify network and mention menu items by checking for group in Model\Contact::photoMenu --- src/Model/Contact.php | 23 ++++++++++++++--------- src/Module/Contact/Hovercard.php | 1 + view/templates/hovercard.tpl | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 48f201e8c2..3e547fcaff 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1199,14 +1199,22 @@ class Contact } if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) { + $mention_label = DI::l10n()->t('Post to group'); $mention_url = 'compose/0?body=!' . $contact['addr']; } else { + $mention_label = DI::l10n()->t('Mention'); $mention_url = 'compose/0?body=@' . $contact['addr']; } $contact_url = 'contact/' . $contact['id']; - $posts_link = 'contact/' . $contact['id'] . '/conversations'; - $group_link = 'network/group/' . $contact['id']; + + if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) { + $network_label = DI::l10n()->t('View group'); + $network_url = 'network/group/' . $contact['id']; + } else { + $network_label = DI::l10n()->t('Network Posts'); + $network_url = 'contact/' . $contact['id'] . '/conversations'; + } $follow_link = ''; $unfollow_link = ''; @@ -1227,26 +1235,23 @@ class Contact if (empty($contact['uid'])) { $menu = [ 'profile' => [DI::l10n()->t('View Profile'), $profile_link, true], - 'network' => [DI::l10n()->t('Network Posts'), $posts_link, false], + 'network' => [$network_label, $network_url, false], 'edit' => [DI::l10n()->t('View Contact'), $contact_url, false], 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link, true], 'unfollow' => [DI::l10n()->t('Unfollow'), $unfollow_link, true], - 'mention' => [DI::l10n()->t('Mention'), DI::l10n()->t('Post to group'), $mention_url, false], - 'group' => [DI::l10n()->t('View group'), $group_link, $contact['forum'], true], + 'mention' => [$mention_label, $mention_url, false], ]; } else { $menu = [ 'status' => [DI::l10n()->t('View Status'), $status_link, true], 'profile' => [DI::l10n()->t('View Profile'), $profile_link, true], 'photos' => [DI::l10n()->t('View Photos'), $photos_link, true], - 'network' => [DI::l10n()->t('Network Posts'), $posts_link, false], + 'network' => [$network_label, $network_url, false], 'edit' => [DI::l10n()->t('View Contact'), $contact_url, false], 'pm' => [DI::l10n()->t('Send PM'), $pm_url, false], 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link, true], 'unfollow' => [DI::l10n()->t('Unfollow'), $unfollow_link, true], - 'mention' => [DI::l10n()->t('Mention'), DI::l10n()->t('Post to group'), $mention_url, false], - 'group' => [DI::l10n()->t('View group'), $group_link, $contact['forum'], true], - 'self' => [$contact['self'] ?? false, true], + 'mention' => [$mention_label, $mention_url, false], ]; if (!empty($contact['pending'])) { diff --git a/src/Module/Contact/Hovercard.php b/src/Module/Contact/Hovercard.php index 9f2fb67bdb..1ca91d056f 100644 --- a/src/Module/Contact/Hovercard.php +++ b/src/Module/Contact/Hovercard.php @@ -112,6 +112,7 @@ class Hovercard extends BaseModule 'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'], 'account_type' => Contact::getAccountType($contact['contact-type']), 'actions' => $actions, + 'self' => $contact['self'], ], ]); diff --git a/view/templates/hovercard.tpl b/view/templates/hovercard.tpl index a7814e5660..70a341035d 100644 --- a/view/templates/hovercard.tpl +++ b/view/templates/hovercard.tpl @@ -21,13 +21,22 @@ {{* here are the different actions like private message, delete and so on *}} {{* @todo we have two different photo menus one for contacts and one for items at the network stream. We currently use the contact photo menu, so the items options are missing We need to move them *}}
- {{if $profile.actions.pm}}{{$profile.actions.pm.0}}{{/if}} + {{if $profile.actions.pm}} + + + {{$profile.actions.pm.0}} + + {{/if}} - {{if $profile.addr && !$profile.actions.self.0}}{{/if}} + {{if $profile.addr && !$profile.self}} + + + {{$profile.actions.mention.0}} + + {{/if}}
- {{if $profile.actions.group.2==1}}{{/if}} {{if $profile.actions.network}}{{/if}} {{if $profile.actions.edit}}{{/if}} {{if $profile.actions.follow}}{{/if}}