<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Model\User;
*/
class HCard extends BaseModule
{
- public static function rawContent(array $parameters = [])
+ protected function content(array $request = []): string
{
- $a = DI::app();
-
- if ((local_user()) && ($parameters['action'] ?? '') === 'view') {
+ if (DI::userSession()->getLocalUserId() && ($this->parameters['action'] ?? '') === 'view') {
// A logged in user views a profile of a user
- $nickname = $a->user['nickname'];
- } elseif (empty($parameters['action'])) {
+ $nickname = DI::app()->getLoggedInUserNickname();
+ } elseif (empty($this->parameters['action'])) {
// Show the profile hCard
- $nickname = $parameters['profile'];
+ $nickname = $this->parameters['profile'];
} else {
throw new HTTPException\NotFoundException(DI::l10n()->t('No profile'));
}
- $profile = Profile::load($a, $nickname, false);
+ $profile = User::getOwnerDataByNick($nickname);
if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
$page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
}
+ $baseUrl = (string)DI::baseUrl();
+
+ $uri = urlencode('acct:' . $profile['nickname'] . '@' . DI::baseUrl()->getHost() . (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : ''));
+
+ $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
+ $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
+ $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl . '/xrd/?uri=' . $uri . '" />' . "\r\n";
+ header('Link: <' . $baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+
+ foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
+ $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";
+ }
+
+ $block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated());
+
// check if blocked
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if ($block) {
$keywords = $profile['pub_keywords'] ?? '';
$keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
if (strlen($keywords)) {
}
}
- $baseUrl = DI::baseUrl();
+ $page['aside'] = Profile::getVCardHtml($profile, $block, false);
- $uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
-
- $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
- $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
- $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
- header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
-
- foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
- $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";
- }
+ return '';
}
}