use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat;
-function item_post(App $a)
+function item_post()
{
$uid = DI::userSession()->getLocalUserId();
*/
private $session;
- /**
- * @deprecated 2022.03
- * @see IHandleUserSessions::isAuthenticated()
- */
- public function isLoggedIn(): bool
- {
- return $this->session->isAuthenticated();
- }
-
- /**
- * @deprecated 2022.03
- * @see IHandleUserSessions::isSiteAdmin()
- */
- public function isSiteAdmin(): bool
- {
- return $this->session->isSiteAdmin();
- }
-
- /**
- * @deprecated 2022.03
- * @see IHandleUserSessions::getLocalUserId()
- */
- public function getLoggedInUserId(): int
- {
- return $this->session->getLocalUserId();
- }
-
- /**
- * @deprecated 2022.03
- * @see IHandleUserSessions::getLocalUserNickname()
- */
- public function getLoggedInUserNickname(): string
- {
- return $this->session->getLocalUserNickname();
- }
-
/**
* Set the profile owner ID
*
// Wrapping HTML responses in the theme template
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
- $response = $page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $nav, $this->session->getLocalUserId());
+ $response = $page->run($this, $this->session, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $nav, $this->session->getLocalUserId());
}
$this->logger->debug('Request processed sucessfully', ['response' => $response->getStatusCode(), 'address' => $server['REMOTE_ADDR'] ?? '', 'request' => $requeststring, 'referer' => $server['HTTP_REFERER'] ?? '', 'user-agent' => $server['HTTP_USER_AGENT'] ?? '', 'duration' => number_format(microtime(true) - $request_start, 3)]);
use Friendica\Core\Logger;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
+use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Module\Response;
*
* @throws HTTPException\InternalServerErrorException
*/
- private function initFooter(App $app, Mode $mode, L10n $l10n)
+ private function initFooter(UserSession $session, Mode $mode, L10n $l10n)
{
// If you're just visiting, let javascript take you home
if (!empty($_SESSION['visitor_home'])) {
$homebase = $_SESSION['visitor_home'];
- } elseif (!empty($app->getLoggedInUserNickname())) {
- $homebase = 'profile/' . $app->getLoggedInUserNickname();
+ } elseif (!empty($session->getLocalUserNickname())) {
+ $homebase = 'profile/' . $session->getLocalUserNickname();
}
if (isset($homebase)) {
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\ServiceUnavailableException
*/
- public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig, Nav $nav, int $localUID)
+ public function run(App $app, UserSession $session, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig, Nav $nav, int $localUID)
{
$moduleName = $args->getModuleName();
/* Build the page ending -- this is stuff that goes right before
* the closing </body> tag
*/
- $this->initFooter($app, $mode, $l10n);
+ $this->initFooter($session, $mode, $l10n);
$profiler->set(microtime(true) - $timestamp, 'aftermath');
*/
public static function getFormSecurityToken(string $typename = ''): string
{
- $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']);
+ $user = User::getById(DI::userSession()->getLocalUserId(), ['guid', 'prvkey']);
$timestamp = time();
$sec_hash = hash('whirlpool', ($user['guid'] ?? '') . ($user['prvkey'] ?? '') . session_id() . $timestamp . $typename);
$max_livetime = 10800; // 3 hours
- $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']);
+ $user = User::getById(DI::userSession()->getLocalUserId(), ['guid', 'prvkey']);
$x = explode('.', $hash);
if (time() > (intval($x[0]) + $max_livetime)) {
public function statusEditor(array $x = [], int $notes_cid = 0, bool $popup = false): string
{
- $user = User::getById($this->app->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
+ $user = User::getById($this->session->getLocalUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
if (empty($user['uid'])) {
return '';
}
if (DI::config()->get('system', 'invitation_only')) {
$x = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining'));
- if ($x || DI::app()->isSiteAdmin()) {
+ if ($x || DI::userSession()->isSiteAdmin()) {
DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
. DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
. '</div>';
$output = $t->replaceMacros($template, $vars);
} catch (Exception $e) {
DI::logger()->critical($e->getMessage(), ['template' => $template, 'vars' => $vars]);
- $message = DI::app()->isSiteAdmin() ?
+ $message = DI::userSession()->isSiteAdmin() ?
$e->getMessage() :
DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
throw new ServiceUnavailableException($message);
$template = $t->getTemplateFile($file, $subDir);
} catch (Exception $e) {
DI::logger()->critical($e->getMessage(), ['file' => $file, 'subDir' => $subDir]);
- $message = DI::app()->isSiteAdmin() ?
+ $message = DI::userSession()->isSiteAdmin() ?
$e->getMessage() :
DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
throw new ServiceUnavailableException($message);
} else {
$admin_message = DI::l10n()->t('template engine cannot be registered without a name.');
DI::logger()->critical($admin_message, ['class' => $class]);
- $message = DI::app()->isSiteAdmin() ?
+ $message = DI::userSession()->isSiteAdmin() ?
$admin_message :
DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
throw new ServiceUnavailableException($message);
$admin_message = DI::l10n()->t('template engine is not registered!');
DI::logger()->critical($admin_message, ['template_engine' => $template_engine]);
- $message = DI::app()->isSiteAdmin() ?
+ $message = DI::userSession()->isSiteAdmin() ?
$admin_message :
DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
throw new ServiceUnavailableException($message);
* @}
*/
- /** @deprecated Use Entity\LocalRelationship::MIRROR_DEACTIVATED instead */
- const MIRROR_DEACTIVATED = LocalRelationship::MIRROR_DEACTIVATED;
- /** @deprecated Now does the same as MIRROR_OWN_POST */
- const MIRROR_FORWARDED = 1;
- /** @deprecated Use Entity\LocalRelationship::MIRROR_OWN_POST instead */
- const MIRROR_OWN_POST = LocalRelationship::MIRROR_OWN_POST;
- /** @deprecated Use Entity\LocalRelationship::MIRROR_NATIVE_RESHARE instead */
- const MIRROR_NATIVE_RESHARE = LocalRelationship::MIRROR_NATIVE_RESHARE;
-
/**
* @param array $fields Array of selected fields, empty for all
* @param array $condition Array of fields for condition
if (DI::userSession()->getLocalUserId() && ($profile['uid'] ?? 0) != DI::userSession()->getLocalUserId()) {
$profile_contact = Contact::getByURL($profile['nurl'], null, [], DI::userSession()->getLocalUserId());
}
- if (!empty($profile['cid']) && self::getMyURL()) {
+ if (!empty($profile['cid']) && DI::userSession()->getMyUrl()) {
$profile_contact = Contact::selectFirst([], ['id' => $profile['cid']]);
}
// Who is the logged-in user to this profile?
$visitor_contact = [];
- if (!empty($profile['uid']) && self::getMyURL()) {
- $visitor_contact = Contact::selectFirst(['rel'], ['uid' => $profile['uid'], 'nurl' => Strings::normaliseLink(self::getMyURL())]);
+ if (!empty($profile['uid']) && DI::userSession()->getMyUrl()) {
+ $visitor_contact = Contact::selectFirst(['rel'], ['uid' => $profile['uid'], 'nurl' => Strings::normaliseLink(DI::userSession()->getMyUrl())]);
}
- $local_user_is_self = self::getMyURL() && ($profile['url'] == self::getMyURL());
- $visitor_is_authenticated = (bool)self::getMyURL();
+ $local_user_is_self = DI::userSession()->getMyUrl() && ($profile['url'] == DI::userSession()->getMyUrl());
+ $visitor_is_authenticated = (bool)DI::userSession()->getMyUrl();
$visitor_is_following =
in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
|| in_array($profile_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND]);
$visitor_is_followed =
in_array($visitor_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND])
|| in_array($profile_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
- $visitor_base_path = self::getMyURL() ? preg_replace('=/profile/(.*)=ism', '', self::getMyURL()) : '';
+ $visitor_base_path = DI::userSession()->getMyUrl() ? preg_replace('=/profile/(.*)=ism', '', DI::userSession()->getMyUrl()) : '';
if (!$local_user_is_self) {
if (!$visitor_is_authenticated) {
]);
}
- /**
- * Retrieves the my_url session variable
- *
- * @return string
- * @deprecated since version 2022.12, please use UserSession->getMyUrl instead
- */
- public static function getMyURL(): string
- {
- return DI::userSession()->getMyUrl();
- }
-
/**
* Process the 'zrl' parameter and initiate the remote authentication.
*
*/
public static function zrlInit(App $a)
{
- $my_url = self::getMyURL();
+ $my_url = DI::userSession()->getMyUrl();
$my_url = Network::isUrlValid($my_url);
if (empty($my_url) || DI::userSession()->getLocalUserId()) {
}
$achar = strpos($url, '?') ? '&' : '?';
- $mine = self::getMyURL();
+ $mine = DI::userSession()->getMyUrl();
if ($mine && !Strings::compareLink($mine, $url)) {
return $url . $achar . 'zrl=' . urlencode($mine);
}
}
- if (!DI::app()->isSiteAdmin()) {
+ if (!DI::userSession()->isSiteAdmin()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
}
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Contact\LocalRelationship;
+use Friendica\Contact\LocalRelationship\Entity\LocalRelationship as LocalRelationshipEntity;
use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode;
if ($contact['network'] == Protocol::FEED) {
$remote_self_options = [
- Contact::MIRROR_DEACTIVATED => $this->t('No mirroring'),
- Contact::MIRROR_OWN_POST => $this->t('Mirror as my own posting')
+ LocalRelationshipEntity::MIRROR_DEACTIVATED => $this->t('No mirroring'),
+ LocalRelationshipEntity::MIRROR_OWN_POST => $this->t('Mirror as my own posting')
];
} elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
$remote_self_options = [
- Contact::MIRROR_DEACTIVATED => $this->t('No mirroring'),
- Contact::MIRROR_NATIVE_RESHARE => $this->t('Native reshare')
+ LocalRelationshipEntity::MIRROR_DEACTIVATED => $this->t('No mirroring'),
+ LocalRelationshipEntity::MIRROR_NATIVE_RESHARE => $this->t('Native reshare')
];
} elseif ($contact['network'] == Protocol::DFRN) {
$remote_self_options = [
- Contact::MIRROR_DEACTIVATED => $this->t('No mirroring'),
- Contact::MIRROR_OWN_POST => $this->t('Mirror as my own posting'),
- Contact::MIRROR_NATIVE_RESHARE => $this->t('Native reshare')
+ LocalRelationshipEntity::MIRROR_DEACTIVATED => $this->t('No mirroring'),
+ LocalRelationshipEntity::MIRROR_OWN_POST => $this->t('Mirror as my own posting'),
+ LocalRelationshipEntity::MIRROR_NATIVE_RESHARE => $this->t('Native reshare')
];
} else {
$remote_self_options = [
- Contact::MIRROR_DEACTIVATED => $this->t('No mirroring'),
- Contact::MIRROR_OWN_POST => $this->t('Mirror as my own posting')
+ LocalRelationshipEntity::MIRROR_DEACTIVATED => $this->t('No mirroring'),
+ LocalRelationshipEntity::MIRROR_OWN_POST => $this->t('Mirror as my own posting')
];
}
if ($config->get('system', 'invitation_only')) {
$invitation_only = true;
$invites_remaining = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining');
- if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
+ if ((!$invites_remaining) && (!DI::userSession()->isSiteAdmin())) {
throw new HTTPException\ForbiddenException();
}
}
continue;
}
- if ($invitation_only && ($invites_remaining || $app->isSiteAdmin())) {
+ if ($invitation_only && ($invites_remaining || DI::userSession()->isSiteAdmin())) {
$code = Model\Register::createForInvitation();
$nmessage = str_replace('$invite_code', $code, $message);
- if (!$app->isSiteAdmin()) {
+ if (!DI::userSession()->isSiteAdmin()) {
$invites_remaining--;
if ($invites_remaining >= 0) {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining', $invites_remaining);
if ($config->get('system', 'invitation_only')) {
$inviteOnly = true;
$x = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining');
- if ((!$x) && (!$app->isSiteAdmin())) {
+ if ((!$x) && (!DI::userSession()->isSiteAdmin())) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
}
}
DI::l10n()->t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linkTxt
. "\r\n" . "\r\n" . (($inviteOnly) ? DI::l10n()->t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . DI::l10n()->t('Once you have registered, please connect with me via my profile page at:')
- . "\r\n" . "\r\n" . DI::baseUrl() . '/profile/' . $app->getLoggedInUserNickname()
+ . "\r\n" . "\r\n" . DI::baseUrl() . '/profile/' . DI::userSession()->getLocalUserNickname()
. "\r\n" . "\r\n" . DI::l10n()->t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n",
],
'$submit' => DI::l10n()->t('Submit')
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
+use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
-use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\User;
/** @var IManageConfigValues */
private $config;
- public function __construct(IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ /** @var UserSession */
+ private $session;
+
+ /** @var App */
+ private $app;
+
+
+ public function __construct(App $app, UserSession $session, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->page = $page;
$this->pConfig = $pConfig;
$this->config = $config;
+ $this->session = $session;
+ $this->app = $app;
}
protected function post(array $request = [])
if (!empty($_REQUEST['body'])) {
$_REQUEST['return'] = 'network';
require_once 'mod/item.php';
- item_post(DI::app());
+ item_post();
} else {
$this->systemMessages->addNotice($this->l10n->t('Please enter a post body.'));
}
protected function content(array $request = []): string
{
- if (!DI::userSession()->getLocalUserId()) {
+ if (!$this->session->getLocalUserId()) {
return Login::form('compose');
}
- $a = DI::app();
-
- if ($a->getCurrentTheme() !== 'frio') {
+ if ($this->app->getCurrentTheme() !== 'frio') {
throw new NotImplementedException($this->l10n->t('This feature is only available with the frio theme.'));
}
}
}
- $user = User::getById(DI::userSession()->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
+ $user = User::getById($this->session->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
$contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
$circle_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
$compose_title = $this->l10n->t('Compose new personal note');
$type = 'note';
$doesFederate = false;
- $contact_allow_list = [$a->getContactId()];
+ $contact_allow_list = [$this->app->getContactId()];
$circle_allow_list = [];
$contact_deny_list = [];
$circle_deny_list = [];
$this->page->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
$this->page->registerFooterScript(Theme::getPathForFile('js/compose.js'));
- $contact = Contact::getById($a->getContactId());
+ $contact = Contact::getById($this->app->getContactId());
- if ($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'set_creation_date')) {
+ if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'set_creation_date')) {
$created_at = Temporal::getDateTimeField(
new \DateTime(DBA::NULL_DATETIME),
new \DateTime('now'),
'location_disabled' => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
'wait' => $this->l10n->t('Please wait'),
'placeholdertitle' => $this->l10n->t('Set title'),
- 'placeholdercategory' => Feature::isEnabled(DI::userSession()->getLocalUserId(), Feature::CATEGORIES) ? $this->l10n->t('Categories (comma-separated list)') : '',
- 'always_open_compose' => $this->pConfig->get(DI::userSession()->getLocalUserId(), 'frio', 'always_open_compose',
+ 'placeholdercategory' => Feature::isEnabled($this->session->getLocalUserId(), Feature::CATEGORIES) ? $this->l10n->t('Categories (comma-separated list)') : '',
+ 'always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose',
$this->config->get('frio', 'always_open_compose', false)) ? '' :
$this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
],
'$jotplugins' => $jotplugins,
'$rand_num' => Crypto::randomDigits(12),
- '$acl_selector' => ACL::getFullSelectorHTML($this->page, $a->getLoggedInUserId(), $doesFederate, [
+ '$acl_selector' => ACL::getFullSelectorHTML($this->page, $this->session->getLocalUserId(), $doesFederate, [
'allow_cid' => $contact_allow_list,
'allow_gid' => $circle_allow_list,
'deny_cid' => $contact_deny_list,
$author = Contact::getById($item['author-id']);
}
- if (Network::isLocalLink($author['url'])) {
+ if ($this->baseUrl->isLocalUrl($author['url'])) {
Profile::load($this->app, $author['nick'], false);
} else {
$this->page['aside'] = Widget\VCard::getHTML($author);
$this->baseUrl->redirect('moderation/blocklist/contact');
}
- if (Network::isLocalLink($contact['nurl'])) {
+ if ($this->baseUrl->isLocalUrl($contact['nurl'])) {
$this->systemMessages->addNotice($this->t('You can\'t block a local contact, please block the user instead'));
$this->baseUrl->redirect('moderation/blocklist/contact');
}
'$ignore' => ['contact_action', $this->t('Ignore contact'), self::CONTACT_ACTION_IGNORE, $this->t("Their posts won't appear in your Network page anymore, but their replies can appear in forum threads. They still can follow you.")],
'$block' => ['contact_action', $this->t('Block contact'), self::CONTACT_ACTION_BLOCK, $this->t("Their posts won't appear in your Network page anymore, but their replies can appear in forum threads, with their content collapsed by default. They cannot follow you but still can have access to your public posts by other means.")],
- '$display_forward' => !Network::isLocalLink($contact['url']),
+ '$display_forward' => !$this->baseUrl->isLocalUrl($contact['url']),
'$forward' => ['report_forward', $this->t('Forward report'), self::CONTACT_ACTION_BLOCK, $this->t('Would you ike to forward this report to the remote server?')],
'$summary' => $this->getAside($request),
'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'],
'default_location' => $is_owner ? $profile['default-location'] : '',
'nickname' => $profile['nickname'],
- 'acl' => $is_owner ? ACL::getFullSelectorHTML($this->page, $this->app->getLoggedInUserId(), true) : '',
+ 'acl' => $is_owner ? ACL::getFullSelectorHTML($this->page, $this->session->getLocalUserId(), true) : '',
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $profile['uid'],
];
{
$visitor_home = null;
if ($this->session->getRemoteUserId()) {
- $visitor_home = Profile::getMyURL();
+ $visitor_home = $this->session->getMyUrl();
$this->cache->delete('zrlInit:' . $visitor_home);
}
$this->session->set('2fa', true);
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser($this->session->getLocalUserId())));
- $this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
+ $this->auth->setForUser($this->app, User::getById($this->session->getLocalUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
} else {
}
try {
- $this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
+ $this->auth->setForUser($this->app, User::getById($this->session->getLocalUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
} catch (FoundException | TemporaryRedirectException | MovedPermanentlyException $e) {
// exception wanted!
throw $e;
} catch (\Exception $e) {
- $this->logger->warning('Unexpected error during authentication.', ['user' => $this->app->getLoggedInUserId(), 'exception' => $exception]);
+ $this->logger->warning('Unexpected error during authentication.', ['user' => $this->session->getLocalUserId(), 'exception' => $exception]);
}
}
}
try {
$trustedBrowser = $this->trustedBrowserRepository->selectOneByHash($this->cookie->get('2fa_cookie_hash'));
if (!$trustedBrowser->trusted) {
- $this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
+ $this->auth->setForUser($this->app, User::getById($this->session->getLocalUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
}
} catch (TrustedBrowserNotFoundException $exception) {
- $this->logger->notice('Trusted Browser of the cookie not found.', ['cookie_hash' => $this->cookie->get('trusted'), 'uid' => $this->app->getLoggedInUserId(), 'exception' => $exception]);
+ $this->logger->notice('Trusted Browser of the cookie not found.', ['cookie_hash' => $this->cookie->get('trusted'), 'uid' => $this->session->getLocalUserId(), 'exception' => $exception]);
} catch (TrustedBrowserPersistenceException $exception) {
- $this->logger->warning('Unexpected persistence exception.', ['cookie_hash' => $this->cookie->get('trusted'), 'uid' => $this->app->getLoggedInUserId(), 'exception' => $exception]);
+ $this->logger->warning('Unexpected persistence exception.', ['cookie_hash' => $this->cookie->get('trusted'), 'uid' => $this->session->getLocalUserId(), 'exception' => $exception]);
} catch (\Exception $exception) {
- $this->logger->warning('Unexpected exception.', ['cookie_hash' => $this->cookie->get('trusted'), 'uid' => $this->app->getLoggedInUserId(), 'exception' => $exception]);
+ $this->logger->warning('Unexpected exception.', ['cookie_hash' => $this->cookie->get('trusted'), 'uid' => $this->session->getLocalUserId(), 'exception' => $exception]);
}
}
{
protected function post(array $request = [])
{
- if (!DI::app()->isLoggedIn()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$a = DI::app();
- $user = User::getById($a->getLoggedInUserId());
+ $user = User::getById($this->session->getLocalUserId());
if (!empty($request['password-submit'])) {
$newpass = $request['password'];
$a = DI::app();
- $user = User::getById($a->getLoggedInUserId());
+ $user = User::getById($this->session->getLocalUserId());
$username = $user['username'];
$email = $user['email'];
'$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid'], 'circle-selection', DI::l10n()->t('Default privacy circle for new contacts')),
'$circle_select_group' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'default-group-gid', $user['def_gid']), 'circle-selection-group', DI::l10n()->t('Default privacy circle for new group contacts')),
'$permissions' => DI::l10n()->t('Default Post Permissions'),
- '$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
+ '$aclselect' => ACL::getFullSelectorHTML(DI::page(), $this->session->getLocalUserId()),
'$expire' => [
'label' => DI::l10n()->t('Expiration settings'),
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
+use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\Database;
{
const IMPORT_DEBUG = false;
- /** @var App */
- private $app;
-
/** @var IManageConfigValues */
private $config;
/** @var PermissionSet */
private $permissionSet;
- public function __construct(PermissionSet $permissionSet, IManagePersonalConfigValues $pconfig, Database $database, SystemMessages $systemMessages, IManageConfigValues $config, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ /** @var UserSession */
+ private $session;
+
+ public function __construct(UserSession $session, PermissionSet $permissionSet, IManagePersonalConfigValues $pconfig, Database $database, SystemMessages $systemMessages, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- $this->app = $app;
$this->config = $config;
$this->pconfig = $pconfig;
$this->systemMessages = $systemMessages;
$this->database = $database;
$this->permissionSet = $permissionSet;
+ $this->session = $session;
}
protected function post(array $request = [])
{
- if (\Friendica\Module\Register::getPolicy() !== \Friendica\Module\Register::OPEN && !$this->app->isSiteAdmin()) {
+ if (\Friendica\Module\Register::getPolicy() !== \Friendica\Module\Register::OPEN && !$this->session->isSiteAdmin()) {
throw new HttpException\ForbiddenException($this->t('Permission denied.'));
}
protected function content(array $request = []): string
{
- if ((\Friendica\Module\Register::getPolicy() !== \Friendica\Module\Register::OPEN) && !$this->app->isSiteAdmin()) {
+ if ((\Friendica\Module\Register::getPolicy() !== \Friendica\Module\Register::OPEN) && !$this->session->isSiteAdmin()) {
$this->systemMessages->addNotice($this->t('User imports on closed servers can only be done by an administrator.'));
}
return CurlResult::createErrorCurl($this->logger, $url);
}
- if (Network::isLocalLink($url)) {
+ if ($this->baseUrl->isLocalUrl($url)) {
$this->logger->info('Local link', ['url' => $url]);
}
{
$this->profiler->startRecording('network');
- if (Network::isLocalLink($url)) {
+ if ($this->baseUrl->isLocalUrl($url)) {
$this->logger->debug('Local link', ['url' => $url]);
}
use Friendica\App\BaseURL;
use Friendica\Content\Text\HTML;
use Friendica\Core\L10n;
+use Friendica\Core\Session\Model\UserSession;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Object\Email;
-use Friendica\Protocol\Email as EmailProtocol;
/**
* Class for creating CC emails based on a received item
*/
class ItemCCEMail extends Email
{
- public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
+ public function __construct(UserSession $session, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
{
- $user = User::getById($a->getLoggedInUserId());
+ $user = User::getById($session->getLocalUserId());
$disclaimer = '<hr />' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $user['username'])
. '<br />';
- $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->getLoggedInUserNickname()) . '<br />';
+ $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $session->getLocalUserNickname()) . '<br />';
$disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . '<br />';
if (!$item['title'] == '') {
$subject = $item['title'];
} else {
$subject = '[Friendica]' . ' ' . $l10n->t('%s posted an update.', $user['username']);
}
- $link = '<a href="' . $baseUrl . '/profile/' . $a->getLoggedInUserNickname() . '"><img src="' . $authorThumb . '" alt="' . $user['username'] . '" /></a><br /><br />';
+ $link = '<a href="' . $baseUrl . '/profile/' . $session->getLocalUserNickname() . '"><img src="' . $authorThumb . '" alt="' . $user['username'] . '" /></a><br /><br />';
$html = Item::prepareBody($item);
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';;
*/
private function getDefaultText(): string
{
- $a = DI::app();
-
if (!DI::userSession()->getLocalUserId()) {
return '';
}
- $owner = User::getOwnerDataById($a->getLoggedInUserId());
+ $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
$item = $this->getData();
if (!empty($item['content-warning']) && Feature::isEnabled(DI::userSession()->getLocalUserId(), Feature::ADD_ABSTRACT)) {
*/
private function getCommentBox(string $indent)
{
- $a = DI::app();
-
$comment_box = '';
$conv = $this->getThread();
$uid = $conv->getProfileOwner();
$parent_uid = $this->getDataValue('uid');
- $owner = User::getOwnerDataById($a->getLoggedInUserId());
+ $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
$default_text = $this->getDefaultText();
if (!is_writable($work_dir)) {
$admin_message = DI::l10n()->t('The folder %s must be writable by webserver.', $work_dir);
DI::logger()->critical($admin_message);
- $message = DI::app()->isSiteAdmin() ?
+ $message = DI::userSession()->isSiteAdmin() ?
$admin_message :
DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
throw new ServiceUnavailableException($message);
}
}
- /**
- * Check if the given URL is a local link
- *
- * @param string $url
- *
- * @return bool
- * @deprecated since 2023.09, please use BaseUrl->isLocalUrl or BaseUrl->isLocalUri instead.
- */
- public static function isLocalLink(string $url): bool
- {
- return DI::baseUrl()->isLocalUrl($url);
- }
-
/**
* Check if the given URL is a valid HTTP/HTTPS URL
*
* If you need to run a script before the database update, name the function "pre_update_4712()"
*/
+use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
function update_1491()
{
- DBA::update('contact', ['remote_self' => Contact::MIRROR_OWN_POST], ['remote_self' => Contact::MIRROR_FORWARDED]);
+ DBA::update('contact', ['remote_self' => LocalRelationship::MIRROR_OWN_POST], ['remote_self' => 1]);
return Update::SUCCESS;
}
}
}
-function theme_admin_post(App $a)
+function theme_admin_post()
{
- if (!$a->isSiteAdmin()) {
+ if (!DI::userSession()->isSiteAdmin()) {
return;
}
{
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
// get the homelink from $_SESSION
- $homelink = Profile::getMyURL();
+ $homelink = DI::userSession()->getMyUrl();
if (!$homelink) {
$homelink = DI::session()->get('visitor_home', '');
}
} elseif (!DI::userSession()->getLocalUserId() && DI::userSession()->getRemoteUserId()) {
$remoteUser = Contact::getById(DI::userSession()->getRemoteUserId(), $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
- } elseif (Profile::getMyURL()) {
+ } elseif (DI::userSession()->getMyUrl()) {
$remoteUser = Contact::getByURL($homelink, null, $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Visitor');
} else {