From 7776c5f690ec11779af2343654482534b1364135 Mon Sep 17 00:00:00 2001 From: very-ape Date: Sun, 23 May 2021 13:25:25 -0700 Subject: [PATCH] Implement code changes from review. --- src/Model/Profile.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 4ce5cfcca3..1943861856 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -267,14 +267,14 @@ class Profile // value is going to be coming from 'owner-view', which means it's the wrong // contact ID for the user viewing this page. Use 'nurl' to look up the // correct contact table entry for the logged-in user. - $is_contact = !empty($profile['nurl']); $profile_contact = []; - if ($is_contact) { + if (!empty($profile['nurl'] ?? '')) { if (local_user() && ($profile['uid'] ?? '') != local_user()) { $profile_contact = Contact::getById(Contact::getIdForURL($profile['nurl'], local_user())); - } else { - $profile_contact = $profile; + } + if (!empty($profile['cid']) && self::getMyURL()) { + $profile_contact = Contact::selectFirst(['rel'], ['id' => $profile['cid']]); } } @@ -349,8 +349,10 @@ class Profile } } - // show edit profile to yourself - if (!$is_contact && $local_user_is_self) { + // show edit profile to yourself, but only if this is not meant to be + // rendered as a "contact". i.e., if 'self' (a "contact" table column) isn't + // set in $profile. + if (!isset($profile['self']) && $local_user_is_self) { $profile['edit'] = [DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'), '', DI::l10n()->t('Edit profile')]; $profile['menu'] = [ 'chg_photo' => DI::l10n()->t('Change profile photo'),