Replace calls of App::setProfileOwner with AppHelper

This commit is contained in:
Art4 2024-11-08 16:20:55 +00:00
parent 9477e1b55f
commit 6a6a5af3b2
5 changed files with 30 additions and 28 deletions

View file

@ -326,15 +326,15 @@ class App implements AppHelper
set_include_path( set_include_path(
get_include_path() . PATH_SEPARATOR get_include_path() . PATH_SEPARATOR
. $this->getBasePath() . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR . $this->appHelper->getBasePath() . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
. $this->getBasePath() . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR . $this->appHelper->getBasePath() . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
. $this->getBasePath()); . $this->appHelper->getBasePath());
$this->profiler->reset(); $this->profiler->reset();
if ($this->mode->has(Mode::DBAVAILABLE)) { if ($this->mode->has(Mode::DBAVAILABLE)) {
Core\Hook::loadHooks(); Core\Hook::loadHooks();
$loader = (new Config())->createConfigFileManager($this->getBasePath(), $_SERVER); $loader = (new Config())->createConfigFileManager($this->appHelper->getBasePath(), $_SERVER);
Core\Hook::callAll('load_config', $loader); Core\Hook::callAll('load_config', $loader);
// Hooks are now working, reload the whole definitions with hook enabled // Hooks are now working, reload the whole definitions with hook enabled
@ -528,7 +528,7 @@ class App implements AppHelper
if ($this->mode->isInstall() && $moduleName !== 'install') { if ($this->mode->isInstall() && $moduleName !== 'install') {
$this->baseURL->redirect('install'); $this->baseURL->redirect('install');
} else { } else {
Core\Update::check($this->getBasePath(), false); Core\Update::check($this->appHelper->getBasePath(), false);
Core\Addon::loadAddons(); Core\Addon::loadAddons();
Core\Hook::loadHooks(); Core\Hook::loadHooks();
} }

View file

@ -9,6 +9,7 @@ namespace Friendica\Model;
use Friendica\App; use Friendica\App;
use Friendica\App\Mode; use Friendica\App\Mode;
use Friendica\AppHelper;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget\ContactBlock; use Friendica\Content\Widget\ContactBlock;
use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Enum\Duration;
@ -199,7 +200,7 @@ class Profile
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function load(App $a, string $nickname, bool $show_contacts = true): array public static function load(AppHelper $appHelper, string $nickname, bool $show_contacts = true): array
{ {
$profile = User::getOwnerDataByNick($nickname); $profile = User::getOwnerDataByNick($nickname);
if (!isset($profile['account_removed']) || $profile['account_removed']) { if (!isset($profile['account_removed']) || $profile['account_removed']) {
@ -213,13 +214,13 @@ class Profile
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$a->setProfileOwner($profile['uid']); $appHelper->setProfileOwner($profile['uid']);
DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename'); DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
if (!DI::userSession()->getLocalUserId()) { if (!DI::userSession()->getLocalUserId()) {
$a->setCurrentTheme($profile['theme']); $appHelper->setCurrentTheme($profile['theme']);
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? ''); $appHelper->setCurrentMobileTheme(DI::pConfig()->get($appHelper->getProfileOwner(), 'system', 'mobile_theme') ?? '');
} }
/* /*
@ -228,7 +229,7 @@ class Profile
Renderer::setActiveTemplateEngine(); // reset the template engine to the default in case the user's theme doesn't specify one Renderer::setActiveTemplateEngine(); // reset the template engine to the default in case the user's theme doesn't specify one
$theme_info_file = 'view/theme/' . $a->getCurrentTheme() . '/theme.php'; $theme_info_file = 'view/theme/' . $appHelper->getCurrentTheme() . '/theme.php';
if (file_exists($theme_info_file)) { if (file_exists($theme_info_file)) {
require_once $theme_info_file; require_once $theme_info_file;
} }

View file

@ -8,6 +8,7 @@
namespace Friendica\Module\Item; namespace Friendica\Module\Item;
use Friendica\App; use Friendica\App;
use Friendica\AppHelper;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content\Conversation; use Friendica\Content\Conversation;
use Friendica\Content\Item as ContentItem; use Friendica\Content\Item as ContentItem;
@ -46,8 +47,8 @@ class Display extends BaseModule
protected $pConfig; protected $pConfig;
/** @var IHandleUserSessions */ /** @var IHandleUserSessions */
protected $session; protected $session;
/** @var App */ /** @var AppHelper */
protected $app; protected $appHelper;
/** @var ContentItem */ /** @var ContentItem */
protected $contentItem; protected $contentItem;
/** @var Conversation */ /** @var Conversation */
@ -57,7 +58,7 @@ class Display extends BaseModule
/** @var Notify */ /** @var Notify */
protected $notify; protected $notify;
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session, App $app, App\Page $page, ContentItem $contentItem, Conversation $conversation, Notification $notification, Notify $notify, array $server, array $parameters = []) public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session, AppHelper $appHelper, App\Page $page, ContentItem $contentItem, Conversation $conversation, Notification $notification, Notify $notify, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
@ -65,7 +66,7 @@ class Display extends BaseModule
$this->config = $config; $this->config = $config;
$this->pConfig = $pConfig; $this->pConfig = $pConfig;
$this->session = $session; $this->session = $session;
$this->app = $app; $this->appHelper = $appHelper;
$this->contentItem = $contentItem; $this->contentItem = $contentItem;
$this->conversation = $conversation; $this->conversation = $conversation;
$this->notification = $notification; $this->notification = $notification;
@ -175,12 +176,12 @@ class Display extends BaseModule
} }
if ($this->baseUrl->isLocalUrl($author['url'])) { if ($this->baseUrl->isLocalUrl($author['url'])) {
Profile::load($this->app, $author['nick'], false); Profile::load($this->appHelper, $author['nick'], false);
} else { } else {
$this->page['aside'] = Widget\VCard::getHTML($author); $this->page['aside'] = Widget\VCard::getHTML($author);
} }
$this->app->setProfileOwner($item['uid']); $this->appHelper->setProfileOwner($item['uid']);
} }
protected function getDisplayData(array $item, bool $update = false, int $updateUid = 0, bool $force = false): string protected function getDisplayData(array $item, bool $update = false, int $updateUid = 0, bool $force = false): string

View file

@ -41,7 +41,7 @@ class Display extends DisplayModule
throw new HTTPException\NotFoundException($this->t('The requested item doesn\'t exist or has been deleted.')); throw new HTTPException\NotFoundException($this->t('The requested item doesn\'t exist or has been deleted.'));
} }
$this->app->setProfileOwner($item['uid'] ?: $profileUid); $this->appHelper->setProfileOwner($item['uid'] ?: $profileUid);
$parentUriId = $item['parent-uri-id']; $parentUriId = $item['parent-uri-id'];
if (empty($force)) { if (empty($force)) {

View file

@ -23,21 +23,21 @@ class Profile extends BaseModule
{ {
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$a = DI::app(); $appHelper = DI::apphelper();
// Ensure we've got a profile owner if updating. // Ensure we've got a profile owner if updating.
$a->setProfileOwner((int)($request['p'] ?? 0)); $appHelper->setProfileOwner((int)($request['p'] ?? 0));
if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($a->getProfileOwner())) { if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($appHelper->getProfileOwner())) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
$remote_contact = DI::userSession()->getRemoteContactID($a->getProfileOwner()); $remote_contact = DI::userSession()->getRemoteContactID($appHelper->getProfileOwner());
$is_owner = DI::userSession()->getLocalUserId() == $a->getProfileOwner(); $is_owner = DI::userSession()->getLocalUserId() == $appHelper->getProfileOwner();
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact; $last_updated_key = "profile:" . $appHelper->getProfileOwner() . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
if (!DI::userSession()->isAuthenticated()) { if (!DI::userSession()->isAuthenticated()) {
$user = User::getById($a->getProfileOwner(), ['hidewall']); $user = User::getById($appHelper->getProfileOwner(), ['hidewall']);
if ($user['hidewall']) { if ($user['hidewall']) {
throw new ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.')); throw new ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
} }
@ -50,7 +50,7 @@ class Profile extends BaseModule
} }
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched their circles // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched their circles
$sql_extra = Item::getPermissionsSQLByUserId($a->getProfileOwner()); $sql_extra = Item::getPermissionsSQLByUserId($appHelper->getProfileOwner());
$last_updated_array = DI::session()->get('last_updated', []); $last_updated_array = DI::session()->get('last_updated', []);
@ -58,7 +58,7 @@ class Profile extends BaseModule
$condition = ["`uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending` $condition = ["`uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
AND `visible` AND (NOT `deleted` OR `gravity` = ?) AND `visible` AND (NOT `deleted` OR `gravity` = ?)
AND `wall` " . $sql_extra, $a->getProfileOwner(), Item::GRAVITY_ACTIVITY]; AND `wall` " . $sql_extra, $appHelper->getProfileOwner(), Item::GRAVITY_ACTIVITY];
if ($request['force'] && !empty($request['item'])) { if ($request['force'] && !empty($request['item'])) {
// When the parent is provided, we only fetch this // When the parent is provided, we only fetch this
@ -90,7 +90,7 @@ class Profile extends BaseModule
$last_updated_array[$last_updated_key] = time(); $last_updated_array[$last_updated_key] = time();
DI::session()->set('last_updated', $last_updated_array); DI::session()->set('last_updated', $last_updated_array);
if ($is_owner && !$a->getProfileOwner() && ProfileModel::shouldDisplayEventList(DI::userSession()->getLocalUserId(), DI::mode())) { if ($is_owner && !$appHelper->getProfileOwner() && ProfileModel::shouldDisplayEventList(DI::userSession()->getLocalUserId(), DI::mode())) {
$o .= ProfileModel::getBirthdays(DI::userSession()->getLocalUserId()); $o .= ProfileModel::getBirthdays(DI::userSession()->getLocalUserId());
$o .= ProfileModel::getEventsReminderHTML(DI::userSession()->getLocalUserId(), DI::userSession()->getPublicContactId()); $o .= ProfileModel::getEventsReminderHTML(DI::userSession()->getLocalUserId(), DI::userSession()->getPublicContactId());
} }
@ -102,7 +102,7 @@ class Profile extends BaseModule
} }
} }
$o .= DI::conversation()->render($items, Conversation::MODE_PROFILE, $a->getProfileOwner(), false, 'received', $a->getProfileOwner()); $o .= DI::conversation()->render($items, Conversation::MODE_PROFILE, $appHelper->getProfileOwner(), false, 'received', $appHelper->getProfileOwner());
System::htmlUpdateExit($o); System::htmlUpdateExit($o);
} }