]> git.mxchange.org Git - friendica.git/commitdiff
Some more deprecated function calls are replaced
authorMichael <heluecht@pirati.ca>
Tue, 14 May 2024 08:37:10 +0000 (08:37 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 14 May 2024 19:21:25 +0000 (19:21 +0000)
30 files changed:
mod/item.php
src/App.php
src/App/Page.php
src/BaseModule.php
src/Content/Conversation.php
src/Content/Widget.php
src/Core/Renderer.php
src/Model/Contact.php
src/Model/Profile.php
src/Module/BaseAdmin.php
src/Module/Contact/Profile.php
src/Module/Invite.php
src/Module/Item/Compose.php
src/Module/Item/Display.php
src/Module/Moderation/Blocklist/Contact.php
src/Module/Moderation/Report/Create.php
src/Module/Profile/Conversations.php
src/Module/Security/Logout.php
src/Module/Security/TwoFactor/Recovery.php
src/Module/Security/TwoFactor/Trust.php
src/Module/Settings/Account.php
src/Module/User/Import.php
src/Network/HTTPClient/Client/HttpClient.php
src/Object/EMail/ItemCCEMail.php
src/Object/Post.php
src/Render/FriendicaSmartyEngine.php
src/Util/Network.php
update.php
view/theme/frio/config.php
view/theme/frio/theme.php

index 6af1e2d221aa5f546a2dcfd6060cadef8d587f81..1f826a42d0f5fd28c305f61e7c7122f9b20a7dd4 100644 (file)
@@ -45,7 +45,7 @@ use Friendica\Model\Post;
 use Friendica\Network\HTTPException;
 use Friendica\Util\DateTimeFormat;
 
-function item_post(App $a)
+function item_post()
 {
        $uid = DI::userSession()->getLocalUserId();
 
index 2e19841a1b4488e60ae75e03647cfdfa5b5a6f54..e10fb44d2dfcd9ccc7f6135af36f78ab5a7cb68d 100644 (file)
@@ -134,42 +134,6 @@ class App
         */
        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
         *
@@ -716,7 +680,7 @@ class App
 
                        // 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)]);
index de170f0411806c9221e5cff05cbd06e5e7dcd184..ab0c95d97c99d41453b62545d9fb66170f0a50d0 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Core\L10n;
 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;
@@ -325,13 +326,13 @@ class Page implements ArrayAccess
         *
         * @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)) {
@@ -420,7 +421,7 @@ class Page implements ArrayAccess
         * @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();
 
@@ -459,7 +460,7 @@ class Page implements ArrayAccess
                /* 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');
 
index 0cf7f514a389ab17f3606155ebcc425095a6f051..2f511bc5471f01e31b591037cc314a4a1861feb1 100644 (file)
@@ -356,7 +356,7 @@ abstract class BaseModule implements ICanHandleRequests
         */
        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);
 
@@ -390,7 +390,7 @@ abstract class BaseModule implements ICanHandleRequests
 
                $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)) {
index 1c5182cc8a51e0354de33421d3ef33c194a8ae76..1979d41a63a55ea5d64db39865d1b5e2b303223c 100644 (file)
@@ -308,7 +308,7 @@ class Conversation
 
        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 '';
                }
index 35455de30aca1245e83ce482b69d57c445c27f8f..8550e44a5eab11fb5ae5fb03e2e6112384e81fcd 100644 (file)
@@ -67,7 +67,7 @@ class Widget
 
                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>';
index 11a7d0a2d676e81bd662c44135f91b5094468ea1..45c8383eeb127130320cd47ad93ac911d0942281 100644 (file)
@@ -87,7 +87,7 @@ class Renderer
                        $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);
@@ -116,7 +116,7 @@ class Renderer
                        $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);
@@ -145,7 +145,7 @@ class Renderer
                } 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);
@@ -179,7 +179,7 @@ class Renderer
 
                $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);
index 7a83d01a0eaa4506103998dfce216977c779922a..d6dfd7b275bbd518a7d92a678639620e4a4073d5 100644 (file)
@@ -113,15 +113,6 @@ class Contact
         * @}
         */
 
-       /** @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
index 4daf77278a4e1b91bd8150cf5757ef7f634a9cd5..3cc1b816e2ae555a2c9f4ccd61133c2818093833 100644 (file)
@@ -297,7 +297,7 @@ class Profile
                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']]);
                }
 
@@ -322,19 +322,19 @@ class Profile
 
                // 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) {
@@ -696,17 +696,6 @@ class Profile
                ]);
        }
 
-       /**
-        * 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.
         *
@@ -730,7 +719,7 @@ class Profile
         */
        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()) {
@@ -916,7 +905,7 @@ class Profile
                }
 
                $achar = strpos($url, '?') ? '&' : '?';
-               $mine = self::getMyURL();
+               $mine = DI::userSession()->getMyUrl();
 
                if ($mine && !Strings::compareLink($mine, $url)) {
                        return $url . $achar . 'zrl=' . urlencode($mine);
index bdcead545fbdea645808b65f836f4676e834a00d..590c9f708a39f0287414d0edc40879b120372a22 100644 (file)
@@ -59,7 +59,7 @@ abstract class BaseAdmin extends BaseModule
                        }
                }
 
-               if (!DI::app()->isSiteAdmin()) {
+               if (!DI::userSession()->isSiteAdmin()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
                }
 
index aee08977f89b0fd07c672612bcf9373baec5f811..fbbf88d5c6f21f68fbffad75208566372390be94 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module\Contact;
 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;
@@ -323,24 +324,24 @@ class Profile extends BaseModule
 
                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')
                        ];
                }
 
index 8e0cff268e47cce257fffc3d0da98dee6287bf88..350ee6beedb1f35ec11e72cce1c397fee14be94b 100644 (file)
@@ -68,7 +68,7 @@ class Invite extends BaseModule
                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();
                        }
                }
@@ -83,11 +83,11 @@ class Invite extends BaseModule
                                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);
@@ -139,7 +139,7 @@ class Invite extends BaseModule
                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'));
                        }
                }
@@ -172,7 +172,7 @@ class Invite extends BaseModule
                                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')
index 80879273e276c89b519310aa2914aa4819f9aa3d..5bb2fc73d5e2b13dd97eb98f8c56a2c9b2354689 100644 (file)
@@ -31,9 +31,9 @@ use Friendica\Core\Hook;
 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;
@@ -64,7 +64,14 @@ class Compose extends BaseModule
        /** @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);
 
@@ -73,6 +80,8 @@ class Compose extends BaseModule
                $this->page           = $page;
                $this->pConfig        = $pConfig;
                $this->config         = $config;
+               $this->session        = $session;
+               $this->app            = $app;
        }
 
        protected function post(array $request = [])
@@ -80,7 +89,7 @@ class Compose extends BaseModule
                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.'));
                }
@@ -88,13 +97,11 @@ class Compose extends BaseModule
 
        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.'));
                }
 
@@ -110,7 +117,7 @@ class Compose extends BaseModule
                        }
                }
 
-               $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']);
@@ -122,7 +129,7 @@ class Compose extends BaseModule
                                $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 = [];
@@ -165,9 +172,9 @@ class Compose extends BaseModule
                $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'),
@@ -205,8 +212,8 @@ class Compose extends BaseModule
                                '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>.'),
                        ],
@@ -237,7 +244,7 @@ class Compose extends BaseModule
 
                        '$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,
index 30aff85b41ea15b919985557dac585ab4d52eea9..f2c22c3090ee51d2669f54589187b145000b563a 100644 (file)
@@ -188,7 +188,7 @@ class Display extends BaseModule
                        $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);
index d726b4d9b3a525e758d35f7619795d8200e1b1bd..fd3161a1a5a84244557e93b9defaf9743f4f41e9 100644 (file)
@@ -66,7 +66,7 @@ class Contact extends BaseModeration
                                $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');
                        }
index a7326fa0fad9f96cbb42a14c98d58807c57b34d3..c2dd4929aff86ddcf0eeba7a6b2ee5547fecf979 100644 (file)
@@ -293,7 +293,7 @@ class Create extends BaseModule
                        '$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),
index 3053f07cb141c9db1b1510e2feb09d46be71f957..41203fecbdf45dd62521c397a986cc3bb4791674 100644 (file)
@@ -157,7 +157,7 @@ class Conversations extends BaseProfile
                                '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'],
                        ];
index 37f4cab371ad3af87f1573104d51ae7408987051..9ec0fa677d1066f2dacc93df4bd96b4e33060980 100644 (file)
@@ -64,7 +64,7 @@ class Logout extends BaseModule
        {
                $visitor_home = null;
                if ($this->session->getRemoteUserId()) {
-                       $visitor_home = Profile::getMyURL();
+                       $visitor_home = $this->session->getMyUrl();
                        $this->cache->delete('zrlInit:' . $visitor_home);
                }
 
index 37a39d556917226ba1d1aaa2ee6d2997991e7f8a..c0aa8646322bf47f586d87a67b9f83ed299ef407 100644 (file)
@@ -73,7 +73,7 @@ class Recovery extends BaseModule
                                $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 {
index 3cb821da4afaba55f4841b9e3e814a91b14b00a3..55c7fd6e86728307be2ce0bb2cd77348aa02bcc6 100644 (file)
@@ -102,13 +102,13 @@ class Trust extends BaseModule
                        }
 
                        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]);
                        }
                }
        }
@@ -123,15 +123,15 @@ class Trust extends BaseModule
                        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]);
                        }
                }
 
index 804cec8325a311fdcd33517c0ba1f9a7111595b0..93c10b024028c890afed32f369d51e60de41cb70 100644 (file)
@@ -46,7 +46,7 @@ class Account extends BaseSettings
 {
        protected function post(array $request = [])
        {
-               if (!DI::app()->isLoggedIn()) {
+               if (!DI::userSession()->isAuthenticated()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
 
@@ -56,7 +56,7 @@ class Account extends BaseSettings
 
                $a = DI::app();
 
-               $user = User::getById($a->getLoggedInUserId());
+               $user = User::getById($this->session->getLocalUserId());
 
                if (!empty($request['password-submit'])) {
                        $newpass = $request['password'];
@@ -394,7 +394,7 @@ class Account extends BaseSettings
 
                $a = DI::app();
 
-               $user = User::getById($a->getLoggedInUserId());
+               $user = User::getById($this->session->getLocalUserId());
 
                $username         = $user['username'];
                $email            = $user['email'];
@@ -591,7 +591,7 @@ class Account extends BaseSettings
                        '$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'),
index d6c54a08aef17a6950b4a8f5b0d5b62e300a562a..f3255cc929d652ae83f16ccf4770981e52b03207 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Core\L10n;
 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;
@@ -48,9 +49,6 @@ class Import extends \Friendica\BaseModule
 {
        const IMPORT_DEBUG = false;
 
-       /** @var App */
-       private $app;
-
        /** @var IManageConfigValues */
        private $config;
 
@@ -66,21 +64,24 @@ class Import extends \Friendica\BaseModule
        /** @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.'));
                }
 
@@ -99,7 +100,7 @@ class Import extends \Friendica\BaseModule
 
        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.'));
                }
 
index 934fe56d93db34b7130ed52a186bad3a9f894874..f6669a20bf3435835f176bd7059ccdd242c19ef1 100644 (file)
@@ -83,7 +83,7 @@ class HttpClient implements ICanSendHttpRequests
                        return CurlResult::createErrorCurl($this->logger, $url);
                }
 
-               if (Network::isLocalLink($url)) {
+               if ($this->baseUrl->isLocalUrl($url)) {
                        $this->logger->info('Local link', ['url' => $url]);
                }
 
@@ -249,7 +249,7 @@ class HttpClient implements ICanSendHttpRequests
        {
                $this->profiler->startRecording('network');
 
-               if (Network::isLocalLink($url)) {
+               if ($this->baseUrl->isLocalUrl($url)) {
                        $this->logger->debug('Local link', ['url' => $url]);
                }
 
index e6991df8c1dbc06d9946dba3e525e3f15c962504..253af96e72d220f5237df895b386e22cf03cae7f 100644 (file)
@@ -25,30 +25,30 @@ use Friendica\App;
 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>';;
 
index b341612e8c1eee702dd73fca06ce410ee6c50f07..cb686840fa638b4ef55b419c70e73678b81c40d2 100644 (file)
@@ -1071,13 +1071,11 @@ class Post
         */
        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)) {
@@ -1124,8 +1122,6 @@ class Post
         */
        private function getCommentBox(string $indent)
        {
-               $a = DI::app();
-
                $comment_box = '';
                $conv = $this->getThread();
 
@@ -1144,7 +1140,7 @@ class Post
                        $uid = $conv->getProfileOwner();
                        $parent_uid = $this->getDataValue('uid');
 
-                       $owner = User::getOwnerDataById($a->getLoggedInUserId());
+                       $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
 
                        $default_text = $this->getDefaultText();
 
index 61dec3c011b1224556f4e7b28e4893f6545235ba..8ead65d0e5e6c962003e0e6cf927f7d4b4034948 100644 (file)
@@ -55,7 +55,7 @@ final class FriendicaSmartyEngine extends TemplateEngine
                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);
index 1c2b3c8e5cdffb7ee93fd6ced5d9b0daee10949e..54eb13bd1214347ede77ab0f1ca5cff638965645 100644 (file)
@@ -648,19 +648,6 @@ class Network
                }
        }
 
-       /**
-        * 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
         *
index f4c491521d0259b8eab3ebfb140bcf4e849664a7..03a95fb145ca3f4afd1f485cd535e55addc9f869 100644 (file)
@@ -40,6 +40,7 @@
  * 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;
@@ -1133,7 +1134,7 @@ function update_1481()
 
 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;
 }
 
index 62969badeb28eb6633803cddec5c939d720e92d7..d7755f8293a4f162535772dfb87fdfeb46214fb5 100644 (file)
@@ -57,9 +57,9 @@ function theme_post(App $a)
        }
 }
 
-function theme_admin_post(App $a)
+function theme_admin_post()
 {
-       if (!$a->isSiteAdmin()) {
+       if (!DI::userSession()->isSiteAdmin()) {
                return;
        }
 
index c316f8dbf59172a43c6c520e4588f9bf27cc4105..a1c40b3b92045af2db9193751f2a3d62d1b2a01c 100644 (file)
@@ -199,7 +199,7 @@ function frio_remote_nav(array &$nav_info)
 {
        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', '');
                }
@@ -212,7 +212,7 @@ function frio_remote_nav(array &$nav_info)
                } 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 {