X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FProfile%2FProfile.php;h=199b96e2c976e4f10b8ff69b5f5e42da1583e310;hb=69b7923df2beed71419bc38e61ca9755fad24b12;hp=dfe537c8c0f196ffa119c2b7c25ba50d49a1015b;hpb=054c301ef0345c4ff9f35cfd08717757eab17b9d;p=friendica.git
diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php
index dfe537c8c0..199b96e2c9 100644
--- a/src/Module/Profile/Profile.php
+++ b/src/Module/Profile/Profile.php
@@ -1,6 +1,6 @@
$parameters['nickname']]);
+ $user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]);
if (DBA::isResult($user)) {
- // The function returns an empty array when the account is removed, expired or blocked
- $data = ActivityPub\Transmitter::getProfile($user['uid']);
- if (!empty($data)) {
+ try {
+ $data = ActivityPub\Transmitter::getProfile($user['uid']);
header('Access-Control-Allow-Origin: *');
header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
System::jsonExit($data, 'application/activity+json');
+ } catch (HTTPException\NotFoundException $e) {
+ System::jsonError(404, ['error' => 'Record not found']);
}
}
- if (DBA::exists('userd', ['username' => $parameters['nickname']])) {
+ if (DBA::exists('userd', ['username' => $this->parameters['nickname']])) {
// Known deleted user
- $data = ActivityPub\Transmitter::getDeletedUser($parameters['nickname']);
+ $data = ActivityPub\Transmitter::getDeletedUser($this->parameters['nickname']);
System::jsonError(410, $data);
} else {
@@ -72,40 +73,39 @@ class Profile extends BaseProfile
}
}
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
$a = DI::app();
- ProfileModel::load($a, $parameters['nickname']);
-
- if (!$a->profile) {
+ $profile = ProfileModel::load($a, $this->parameters['nickname']);
+ if (!$profile) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
}
- $remote_contact_id = Session::getRemoteContactID($a->profile_uid);
+ $remote_contact_id = Session::getRemoteContactID($profile['uid']);
if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) {
return Login::form();
}
- $is_owner = local_user() == $a->profile_uid;
+ $is_owner = local_user() == $profile['uid'];
- if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) {
+ if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
}
- if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
+ if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
DI::page()['htmlhead'] .= '' . "\n";
}
- DI::page()['htmlhead'] .= self::buildHtmlHead($a->profile, $parameters['nickname'], $remote_contact_id);
+ DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $this->parameters['nickname'], $remote_contact_id);
Nav::setSelected('home');
- $is_owner = local_user() == $a->profile['uid'];
- $o = self::getTabsHTML($a, 'profile', $is_owner, $a->profile['nickname']);
+ $is_owner = local_user() == $profile['uid'];
+ $o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
- if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) {
+ if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
notice(DI::l10n()->t('Access to this profile has been restricted.'));
return '';
}
@@ -134,66 +134,70 @@ class Profile extends BaseProfile
$view_as_contact_alert = DI::l10n()->t(
'You\'re currently viewing your profile as %s Cancel',
htmlentities($view_as_contacts[$key]['name'], ENT_COMPAT, 'UTF-8'),
- 'profile/' . $parameters['nickname'] . '/profile'
+ 'profile/' . $this->parameters['nickname'] . '/profile'
);
}
}
$basic_fields = [];
- $basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $a->profile['name']);
+ $basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $profile['name']);
- if (Feature::isEnabled($a->profile_uid, 'profile_membersince')) {
+ if (Feature::isEnabled($profile['uid'], 'profile_membersince')) {
$basic_fields += self::buildField(
'membersince',
DI::l10n()->t('Member since:'),
- DateTimeFormat::local($a->profile['register_date'])
+ DateTimeFormat::local($profile['register_date'])
);
}
- if (!empty($a->profile['dob']) && $a->profile['dob'] > DBA::NULL_DATE) {
+ if (!empty($profile['dob']) && $profile['dob'] > DBA::NULL_DATE) {
$year_bd_format = DI::l10n()->t('j F, Y');
$short_bd_format = DI::l10n()->t('j F');
$dob = DI::l10n()->getDay(
- intval($a->profile['dob']) ?
- DateTimeFormat::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
- : DateTimeFormat::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
+ intval($profile['dob']) ?
+ DateTimeFormat::utc($profile['dob'] . ' 00:00 +00:00', $year_bd_format)
+ : DateTimeFormat::utc('2001-' . substr($profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
);
$basic_fields += self::buildField('dob', DI::l10n()->t('Birthday:'), $dob);
- if ($age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'])) {
+ if ($age = Temporal::getAgeByTimezone($profile['dob'], $profile['timezone'])) {
$basic_fields += self::buildField('age', DI::l10n()->t('Age: '), DI::l10n()->tt('%d year old', '%d years old', $age));
}
}
- if ($a->profile['about']) {
- $basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convert($a->profile['about']));
+ if ($profile['about']) {
+ $basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
+ }
+
+ if ($profile['xmpp']) {
+ $basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $profile['xmpp']);
}
- if ($a->profile['xmpp']) {
- $basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $a->profile['xmpp']);
+ if ($profile['matrix']) {
+ $basic_fields += self::buildField('matrix', DI::l10n()->t('Matrix:'), $profile['matrix']);
}
- if ($a->profile['homepage']) {
- $basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($a->profile['homepage']));
+ if ($profile['homepage']) {
+ $basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($profile['homepage']));
}
if (
- $a->profile['address']
- || $a->profile['locality']
- || $a->profile['postal-code']
- || $a->profile['region']
- || $a->profile['country-name']
+ $profile['address']
+ || $profile['locality']
+ || $profile['postal-code']
+ || $profile['region']
+ || $profile['country-name']
) {
- $basic_fields += self::buildField('location', DI::l10n()->t('Location:'), ProfileModel::formatLocation($a->profile));
+ $basic_fields += self::buildField('location', DI::l10n()->t('Location:'), ProfileModel::formatLocation($profile));
}
- if ($a->profile['pub_keywords']) {
+ if ($profile['pub_keywords']) {
$tags = [];
// Separator is defined in Module\Settings\Profile\Index::cleanKeywords
- foreach (explode(', ', $a->profile['pub_keywords']) as $tag_label) {
+ foreach (explode(', ', $profile['pub_keywords']) as $tag_label) {
$tags[] = [
'url' => '/search?tag=' . $tag_label,
'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label,
@@ -209,26 +213,26 @@ class Profile extends BaseProfile
$contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0;
if ($is_owner && $contact_id === 0) {
- $profile_fields = DI::profileField()->selectByUserId($a->profile_uid);
+ $profile_fields = DI::profileField()->selectByUserId($profile['uid']);
} else {
- $profile_fields = DI::profileField()->selectByContactId($contact_id, $a->profile_uid);
+ $profile_fields = DI::profileField()->selectByContactId($contact_id, $profile['uid']);
}
foreach ($profile_fields as $profile_field) {
$custom_fields += self::buildField(
'custom_' . $profile_field->order,
$profile_field->label,
- BBCode::convert($profile_field->value),
+ BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
'aprofile custom'
);
};
//show subcribed forum if it is enabled in the usersettings
- if (Feature::isEnabled($a->profile_uid, 'forumlist_profile')) {
+ if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
$custom_fields += self::buildField(
'forumlist',
DI::l10n()->t('Forums:'),
- ForumManager::profileAdvanced($a->profile_uid)
+ ForumManager::profileAdvanced($profile['uid'])
);
}
@@ -243,11 +247,11 @@ class Profile extends BaseProfile
'$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'),
- '$is_owner' => $a->profile_uid == local_user(),
+ '$is_owner' => $profile['uid'] == local_user(),
'$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields,
- '$profile' => $a->profile,
+ '$profile' => $profile,
'$edit_link' => [
'url' => DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'),
'title' => '',