mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:40:17 +00:00
Replace calls of App::setProfileOwner with AppHelper
This commit is contained in:
parent
9477e1b55f
commit
6a6a5af3b2
5 changed files with 30 additions and 28 deletions
10
src/App.php
10
src/App.php
|
@ -326,15 +326,15 @@ class App implements AppHelper
|
|||
|
||||
set_include_path(
|
||||
get_include_path() . PATH_SEPARATOR
|
||||
. $this->getBasePath() . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
|
||||
. $this->getBasePath() . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
|
||||
. $this->getBasePath());
|
||||
. $this->appHelper->getBasePath() . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
|
||||
. $this->appHelper->getBasePath() . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
|
||||
. $this->appHelper->getBasePath());
|
||||
|
||||
$this->profiler->reset();
|
||||
|
||||
if ($this->mode->has(Mode::DBAVAILABLE)) {
|
||||
Core\Hook::loadHooks();
|
||||
$loader = (new Config())->createConfigFileManager($this->getBasePath(), $_SERVER);
|
||||
$loader = (new Config())->createConfigFileManager($this->appHelper->getBasePath(), $_SERVER);
|
||||
Core\Hook::callAll('load_config', $loader);
|
||||
|
||||
// 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') {
|
||||
$this->baseURL->redirect('install');
|
||||
} else {
|
||||
Core\Update::check($this->getBasePath(), false);
|
||||
Core\Update::check($this->appHelper->getBasePath(), false);
|
||||
Core\Addon::loadAddons();
|
||||
Core\Hook::loadHooks();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Friendica\Model;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Widget\ContactBlock;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
|
@ -199,7 +200,7 @@ class Profile
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @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);
|
||||
if (!isset($profile['account_removed']) || $profile['account_removed']) {
|
||||
|
@ -213,13 +214,13 @@ class Profile
|
|||
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');
|
||||
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
$a->setCurrentTheme($profile['theme']);
|
||||
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? '');
|
||||
$appHelper->setCurrentTheme($profile['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
|
||||
|
||||
$theme_info_file = 'view/theme/' . $a->getCurrentTheme() . '/theme.php';
|
||||
$theme_info_file = 'view/theme/' . $appHelper->getCurrentTheme() . '/theme.php';
|
||||
if (file_exists($theme_info_file)) {
|
||||
require_once $theme_info_file;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Conversation;
|
||||
use Friendica\Content\Item as ContentItem;
|
||||
|
@ -46,8 +47,8 @@ class Display extends BaseModule
|
|||
protected $pConfig;
|
||||
/** @var IHandleUserSessions */
|
||||
protected $session;
|
||||
/** @var App */
|
||||
protected $app;
|
||||
/** @var AppHelper */
|
||||
protected $appHelper;
|
||||
/** @var ContentItem */
|
||||
protected $contentItem;
|
||||
/** @var Conversation */
|
||||
|
@ -57,7 +58,7 @@ class Display extends BaseModule
|
|||
/** @var 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);
|
||||
|
||||
|
@ -65,7 +66,7 @@ class Display extends BaseModule
|
|||
$this->config = $config;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->session = $session;
|
||||
$this->app = $app;
|
||||
$this->appHelper = $appHelper;
|
||||
$this->contentItem = $contentItem;
|
||||
$this->conversation = $conversation;
|
||||
$this->notification = $notification;
|
||||
|
@ -175,12 +176,12 @@ class Display extends BaseModule
|
|||
}
|
||||
|
||||
if ($this->baseUrl->isLocalUrl($author['url'])) {
|
||||
Profile::load($this->app, $author['nick'], false);
|
||||
Profile::load($this->appHelper, $author['nick'], false);
|
||||
} else {
|
||||
$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
|
||||
|
|
|
@ -41,7 +41,7 @@ class Display extends DisplayModule
|
|||
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'];
|
||||
|
||||
if (empty($force)) {
|
||||
|
|
|
@ -23,21 +23,21 @@ class Profile extends BaseModule
|
|||
{
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$a = DI::app();
|
||||
$appHelper = DI::apphelper();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
$remote_contact = DI::userSession()->getRemoteContactID($a->getProfileOwner());
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $a->getProfileOwner();
|
||||
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
|
||||
$remote_contact = DI::userSession()->getRemoteContactID($appHelper->getProfileOwner());
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $appHelper->getProfileOwner();
|
||||
$last_updated_key = "profile:" . $appHelper->getProfileOwner() . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
|
||||
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
$user = User::getById($a->getProfileOwner(), ['hidewall']);
|
||||
$user = User::getById($appHelper->getProfileOwner(), ['hidewall']);
|
||||
if ($user['hidewall']) {
|
||||
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
|
||||
$sql_extra = Item::getPermissionsSQLByUserId($a->getProfileOwner());
|
||||
$sql_extra = Item::getPermissionsSQLByUserId($appHelper->getProfileOwner());
|
||||
|
||||
$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`
|
||||
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'])) {
|
||||
// When the parent is provided, we only fetch this
|
||||
|
@ -90,7 +90,7 @@ class Profile extends BaseModule
|
|||
$last_updated_array[$last_updated_key] = time();
|
||||
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::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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue