Implement code changes from review.

This commit is contained in:
very-ape 2021-05-23 13:25:25 -07:00
parent b2bc911eb2
commit 7776c5f690

View file

@ -267,14 +267,14 @@ class Profile
// value is going to be coming from 'owner-view', which means it's the wrong // 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 // contact ID for the user viewing this page. Use 'nurl' to look up the
// correct contact table entry for the logged-in user. // correct contact table entry for the logged-in user.
$is_contact = !empty($profile['nurl']);
$profile_contact = []; $profile_contact = [];
if ($is_contact) { if (!empty($profile['nurl'] ?? '')) {
if (local_user() && ($profile['uid'] ?? '') != local_user()) { if (local_user() && ($profile['uid'] ?? '') != local_user()) {
$profile_contact = Contact::getById(Contact::getIdForURL($profile['nurl'], 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 // show edit profile to yourself, but only if this is not meant to be
if (!$is_contact && $local_user_is_self) { // 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['edit'] = [DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'), '', DI::l10n()->t('Edit profile')];
$profile['menu'] = [ $profile['menu'] = [
'chg_photo' => DI::l10n()->t('Change profile photo'), 'chg_photo' => DI::l10n()->t('Change profile photo'),